SourceXtractorPlusPlus  0.10
Please provide a description of the project.
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 
66  std::vector<DetectionImage::PixelType> data (width * height);
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 
SourceXtractor::PixelBoundaries
The bounding box of all the pixels in the source. Both min and max coordinate are inclusive.
Definition: PixelBoundaries.h:37
std::lock
T lock(T... args)
SourceXtractor::PixelCoordinate
A pixel coordinate made of two integers m_x and m_y.
Definition: PixelCoordinate.h:37
PixelBoundaries.h
std::shared_ptr
STL class.
std::vector< DetectionImage::PixelType >
DetectionFrame.h
std::lock_guard
STL class.
SourceXtractor::MultithreadedMeasurement::g_global_mutex
static std::recursive_mutex g_global_mutex
Definition: MultithreadedMeasurement.h:54
VectorImage.h
SourceXtractor
Definition: Aperture.h:30
SourceXtractor::DetectionFrameSourceStamp
A copy of the rectangular region of the detection image just large enough to include the whole Source...
Definition: DetectionFrameSourceStamp.h:36
SourceXtractor::DetectionFrame
Definition: DetectionFrame.h:33
SourceXtractor::VectorImage::create
static std::shared_ptr< VectorImage< T > > create(Args &&... args)
Definition: VectorImage.h:89
Image.h
std::min
T min(T... args)
DetectionFrameSourceStamp.h
x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
Definition: MoffatModelFittingTask.cpp:93
MultithreadedMeasurement.h
DetectionFrameSourceStampTask.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
std::max
T max(T... args)
y
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Definition: MoffatModelFittingTask.cpp:93
SourceXtractor::DetectionFrameSourceStampTask::computeProperties
virtual void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
Definition: DetectionFrameSourceStampTask.cpp:37
SourceXtractor::SourceInterface::setProperty
void setProperty(Args... args)
Definition: SourceInterface.h:72