SourceXtractorPlusPlus  0.11
Please provide a description of the project.
VignetSourceTask.cpp
Go to the documentation of this file.
1 
33 
34 namespace SourceXtractor {
37 
38  // pixel and mask from the measurement frame
39  const auto& measurement_frame = source.getProperty<MeasurementFrame>(m_instance).getFrame();
40  const auto& measurement_sub_image = measurement_frame->getSubtractedImage();
41  const auto& measurement_var_image = measurement_frame->getVarianceMap();
42  const auto& measurement_var_threshold = measurement_frame->getVarianceThreshold();
43 
44  // neighbor masking from the detection image
45  const auto& detection_frame = source.getProperty<DetectionFrame>().getFrame();
46  const auto& detection_thresh_image = detection_frame->getThresholdedImage();
47 
48  // get the object pixel coordinates from the detection image
49  const auto& pixel_coords = source.getProperty<PixelCoordinateList>();
50 
51  // coordinate systems
52  auto detection_coordinate_system = detection_frame->getCoordinateSystem();
53  auto measurement_coordinate_system = measurement_frame->getCoordinateSystem();
54 
55  // get the central pixel coord
56  const auto& centroid = source.getProperty<MeasurementFramePixelCentroid>(m_instance);
57  const int x_pix = static_cast<int>(centroid.getCentroidX() + 0.5);
58  const int y_pix = static_cast<int>(centroid.getCentroidY() + 0.5);
59 
60  // get the sub-image boundaries
61  int x_start = x_pix - m_vignet_size[0] / 2;
62  int y_start = y_pix - m_vignet_size[1] / 2;
63  int x_end = x_start + m_vignet_size[0];
64  int y_end = y_start + m_vignet_size[1];
65 
66  // create and fill the vignet vector using the measurement frame
68  int index = 0;
69  for (int iy = y_start; iy < y_end; iy++) {
70  for (int ix = x_start; ix < x_end; ix++, index++) {
71 
72  // skip pixels outside of the image
73  if (ix < 0 || iy < 0 || ix >= measurement_sub_image->getWidth() || iy >= measurement_sub_image->getHeight())
74  continue;
75 
76  // translate pixel coordinates to the detection frame
77  auto world_coord = measurement_coordinate_system->imageToWorld({static_cast<double>(ix), static_cast<double>(iy)});
78  auto detection_coord = detection_coordinate_system->worldToImage(world_coord);
79 
80  // copy the pixel value if it is not masked, and if it does not correspond to a detection pixel
81  // if it corresponds to a detection pixel, use it if it belongs to the source
82  int detection_x = static_cast<int>(detection_coord.m_x + 0.5);
83  int detection_y = static_cast<int>(detection_coord.m_y + 0.5);
84 
85  bool is_masked = measurement_var_image->getValue(ix, iy) > measurement_var_threshold;
86  bool is_detection_pixel = detection_thresh_image->getValue(detection_x, detection_y) > 0;
87 
88  if (!is_masked && (!is_detection_pixel || pixel_coords.contains({detection_x, detection_y}))) {
89  vignet_vector[index] = measurement_sub_image->getValue(ix, iy);
90  }
91  }
92  }
93 
94  // set the property
95  source.setIndexedProperty<Vignet>(m_instance,
96  VectorImage<DetectionImage::PixelType>::create(m_vignet_size[0], m_vignet_size[1], std::move(vignet_vector)));
97 }
98 } // namespace SourceXtractor
PixelCoordinateList.h
SourceXtractor::PixelCoordinateList
Definition: PixelCoordinateList.h:31
MeasurementFrame.h
std::lock
T lock(T... args)
std::move
T move(T... args)
MeasurementFramePixelCentroid.h
SourceXtractor::MeasurementFramePixelCentroid
Definition: MeasurementFramePixelCentroid.h:31
std::vector< SeFloat >
Vignet.h
VignetSourceTask.h
DetectionFrame.h
std::lock_guard
STL class.
SourceXtractor::MultithreadedMeasurement::g_global_mutex
static std::recursive_mutex g_global_mutex
Definition: MultithreadedMeasurement.h:54
SourceXtractor::Vignet
Definition: Vignet.h:33
SourceXtractor
Definition: Aperture.h:30
SourceXtractor::DetectionFrame
Definition: DetectionFrame.h:33
SourceXtractor::VectorImage::create
static std::shared_ptr< VectorImage< T > > create(Args &&... args)
Definition: VectorImage.h:89
SourceXtractor::MeasurementFrame
Definition: MeasurementFrame.h:36
SourceXtractor::VignetSourceTask::m_vignet_default_pixval
SeFloat m_vignet_default_pixval
Definition: VignetSourceTask.h:45
SourceXtractor::VignetSourceTask::m_instance
unsigned m_instance
Definition: VignetSourceTask.h:43
SourceXtractor::VignetSourceTask::m_vignet_size
std::array< int, 2 > m_vignet_size
Definition: VignetSourceTask.h:44
SourceXtractor::VignetSourceTask::computeProperties
virtual void computeProperties(SourceInterface &source) const
Computes one or more properties for the Source.
Definition: VignetSourceTask.cpp:35
MultithreadedMeasurement.h
SourceXtractor::SourceInterface::getProperty
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
Definition: SourceInterface.h:57
SourceXtractor::SourceInterface
The SourceInterface is an abstract "source" that has properties attached to it.
Definition: SourceInterface.h:46
PixelCentroid.h