SourceXtractorPlusPlus  0.11
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DetectionFrameSourceStampTask.cpp
Go to the documentation of this file.
1 
23 #include <mutex>
24 
29 
32 
34 
35 namespace SourceXtractor {
36 
39 
40  auto detection_frame = source.getProperty<DetectionFrame>().getFrame();
41  auto subtracted_image = detection_frame->getSubtractedImage();
42  auto thresholded_image = detection_frame->getThresholdedImage();
43  auto variance_map = detection_frame->getVarianceMap();
44  auto threshold_map = detection_frame->getDetectionThresholdMap();
45 
46  const auto& boundaries = source.getProperty<PixelBoundaries>();
47  auto min = boundaries.getMin();
48  auto max = boundaries.getMax();
49 
50 
51  // FIXME temporary, for now just enlarge the area by a fixed amount of pixels
52  PixelCoordinate border = (max - min) * .8 + PixelCoordinate(2, 2);
53 
54  min -= border;
55  max += border;
56 
57  // clip to image size
58  min.m_x = std::max(min.m_x, 0);
59  min.m_y = std::max(min.m_y, 0);
60  max.m_x = std::min(max.m_x, subtracted_image->getWidth() - 1);
61  max.m_y = std::min(max.m_y, subtracted_image->getHeight() - 1);
62 
63  auto width = max.m_x - min.m_x +1;
64  auto height = max.m_y - min.m_y + 1;
65 
67  std::vector<DetectionImage::PixelType> thresholded_data (width * height);
68  std::vector<DetectionImage::PixelType> variance_data (width * height);
69  std::vector<DetectionImage::PixelType> threshold_map_data (width * height);
70 
71  for (auto x = min.m_x; x <= max.m_x; ++x) {
72  for (auto y = min.m_y; y <= max.m_y; ++y) {
73  auto index = (x-min.m_x) + (y-min.m_y) * width;
74  data[index] = subtracted_image->getValue(x, y);
75  thresholded_data[index] = thresholded_image->getValue(x, y);
76  variance_data[index] = variance_map->getValue(x, y);
77  threshold_map_data[index] = threshold_map->getValue(x, y);
78  }
79  }
80 
82  std::shared_ptr<DetectionImage> thresholded_stamp =
83  VectorImage<DetectionImage::PixelType>::create(width, height, thresholded_data);
84  std::shared_ptr<WeightImage> variance_stamp =
85  VectorImage<WeightImage::PixelType>::create(width, height, variance_data);
86  std::shared_ptr<DetectionImage> threshold_map_stamp =
87  VectorImage<DetectionImage::PixelType>::create(width, height, threshold_map_data);
88 
89  source.setProperty<DetectionFrameSourceStamp>(stamp, thresholded_stamp, min, variance_stamp, threshold_map_stamp);
90 }
91 
92 } // SEImplementation namespace
93 
94 
95 
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
The bounding box of all the pixels in the source. Both min and max coordinate are inclusive...
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
static std::shared_ptr< VectorImage< T > > create(Args &&...args)
Definition: VectorImage.h:89
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
T min(T...args)
A copy of the rectangular region of the detection image just large enough to include the whole Source...
T lock(T...args)
T max(T...args)
A pixel coordinate made of two integers m_x and m_y.
STL class.
virtual void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
The SourceInterface is an abstract &quot;source&quot; that has properties attached to it.