SourceXtractorPlusPlus 0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
MeasurementFrameRectangleTaskNoDetect.cpp
Go to the documentation of this file.
1
18#include <iostream>
19
26
29
30namespace SourceXtractor {
31
33 auto measurement_frame_coordinates = source.getProperty<MeasurementFrameCoordinates>(m_instance).getCoordinateSystem();
35 const auto& world_centroid = source.getProperty<WorldCentroid>();
36 const auto& assoc_mode = source.getProperty<AssocMode>();
37
38 auto coord = world_centroid.getCentroid();
39
40 bool bad_coordinates = false;
42 try {
43 int sz = assoc_mode.getRefFramePixelRadius();
44 auto c = measurement_frame_coordinates->worldToImage(coord);
45 coord1 = ImageCoordinate(c.m_x - sz, c.m_y - sz);
46 coord2 = ImageCoordinate(c.m_x + sz, c.m_y - sz);
47 coord3 = ImageCoordinate(c.m_x - sz, c.m_y + sz);
48 coord4 = ImageCoordinate(c.m_x + sz, c.m_y + sz);
49 }
50 catch (const InvalidCoordinatesException&) {
51 bad_coordinates = true;
52 }
53
54 // Determine the min/max coordinates
55 auto min_x = std::min(coord1.m_x, std::min(coord2.m_x, std::min(coord3.m_x, coord4.m_x)));
56 auto min_y = std::min(coord1.m_y, std::min(coord2.m_y, std::min(coord3.m_y, coord4.m_y)));
57 auto max_x = std::max(coord1.m_x, std::max(coord2.m_x, std::max(coord3.m_x, coord4.m_x)));
58 auto max_y = std::max(coord1.m_y, std::max(coord2.m_y, std::max(coord3.m_y, coord4.m_y)));
59
61 min_coord.m_x = int(min_x);
62 min_coord.m_y = int(min_y);
63 max_coord.m_x = int(max_x) + 1;
64 max_coord.m_y = int(max_y) + 1;
65
66 // The full boundaries may lie outside of the frame
67 if (bad_coordinates || max_coord.m_x < 0 || max_coord.m_y < 0 ||
68 min_coord.m_x >= measurement_frame_info.getWidth() || min_coord.m_y >= measurement_frame_info.getHeight()) {
70 }
71 // Clip the coordinates to fit the available image
72 else {
73 min_coord.m_x = std::max(0, min_coord.m_x);
74 min_coord.m_y = std::max(0, min_coord.m_y);
75 max_coord.m_x = std::min(measurement_frame_info.getWidth() - 1, max_coord.m_x);
76 max_coord.m_y = std::min(measurement_frame_info.getHeight() - 1, max_coord.m_y);
77
79 }
80}
81
82} // SEImplementation namespace
83
void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
The SourceInterface is an abstract "source" that has properties attached to it.
T max(T... args)
T min(T... args)
A pixel coordinate made of two integers m_x and m_y.