SourceXtractorPlusPlus 0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
VignetSourceTask.cpp
Go to the documentation of this file.
1
33
36
37namespace SourceXtractor {
41
42 auto measurement_var_threshold = measurement_frame_info.getVarianceThreshold();
43
46
47 // neighbor masking from the detection image
48 const auto& detection_frame_images = source.getProperty<DetectionFrameImages>();
50
51 // get the object pixel coordinates from the detection image
52 const auto& pixel_coords = source.getProperty<PixelCoordinateList>();
53
54 // coordinate systems
55 auto detection_coordinate_system = source.getProperty<DetectionFrameCoordinates>().getCoordinateSystem();
56 auto measurement_coordinate_system = source.getProperty<MeasurementFrameCoordinates>(m_instance).getCoordinateSystem();
57
58 // get the central pixel coord
59 const auto& centroid = source.getProperty<MeasurementFramePixelCentroid>(m_instance);
60 const int x_pix = static_cast<int>(centroid.getCentroidX() + 0.5);
61 const int y_pix = static_cast<int>(centroid.getCentroidY() + 0.5);
62
63 // get the sub-image boundaries
64 int x_start = x_pix - m_vignet_size[0] / 2;
65 int y_start = y_pix - m_vignet_size[1] / 2;
66 int x_end = x_start + m_vignet_size[0];
67 int y_end = y_start + m_vignet_size[1];
68
69 // create and fill the vignet vector using the measurement frame
71 int index = 0;
72 for (int iy = y_start; iy < y_end; iy++) {
73 for (int ix = x_start; ix < x_end; ix++, index++) {
74
75 // skip pixels outside of the image
76 if (ix < 0 || iy < 0 || ix >= measurement_sub_image->getWidth() || iy >= measurement_sub_image->getHeight())
77 continue;
78
79 // translate pixel coordinates to the detection frame
80 auto world_coord = measurement_coordinate_system->imageToWorld({static_cast<double>(ix), static_cast<double>(iy)});
81 auto detection_coord = detection_coordinate_system->worldToImage(world_coord);
82
83 // copy the pixel value if it is not masked, and if it does not correspond to a detection pixel
84 // if it corresponds to a detection pixel, use it if it belongs to the source
85 int detection_x = static_cast<int>(detection_coord.m_x + 0.5);
86 int detection_y = static_cast<int>(detection_coord.m_y + 0.5);
87
90
92 vignet_vector[index] = measurement_sub_image->getValue(ix, iy);
93 }
94 }
95 }
96
97 // set the property
98 source.setIndexedProperty<Vignet>(m_instance,
99 VectorImage<DetectionImage::PixelType>::create(m_vignet_size[0], m_vignet_size[1], std::move(vignet_vector)));
100}
101} // namespace SourceXtractor
The SourceInterface is an abstract "source" that has properties attached to it.
static std::shared_ptr< VectorImage< T > > create(Args &&... args)
virtual void computeProperties(SourceInterface &source) const
Computes one or more properties for the Source.
T move(T... args)
@ LayerVarianceMap
Definition Frame.h:45
@ LayerThresholdedImage
Definition Frame.h:41
@ LayerSubtractedImage
Definition Frame.h:39