SourceXtractorPlusPlus  0.11
Please provide a description of the project.
DetectionFrameGroupStampTask.cpp
Go to the documentation of this file.
1 
17 /*
18  * DetectionFrameGroupStampTask.cpp
19  *
20  * Created on: May 5, 2017
21  * Author: mschefer
22  */
23 
24 #include <iostream>
25 #include <mutex>
26 
31 
34 
36 
37 namespace SourceXtractor {
38 
41 
42  // FIXME we are obviously assuming the same DetectionFrame for all sources but we should not have to rely on that
43  auto detection_frame = group.cbegin()->getProperty<DetectionFrame>().getFrame();
44  auto subtracted_image = detection_frame->getSubtractedImage();
45  auto thresholded_image = detection_frame->getThresholdedImage();
46  auto variance_map = detection_frame->getVarianceMap();
47 
49  int min_x = INT_MAX;
50  int min_y = INT_MAX;
51  int max_x = INT_MIN;
52  int max_y = INT_MIN;
53 
54  for (auto& source : group) {
55  const auto& boundaries = source.getProperty<PixelBoundaries>();
56  const auto& min = boundaries.getMin();
57  const auto& max = boundaries.getMax();
58 
59  min_x = std::min(min_x, min.m_x);
60  min_y = std::min(min_y, min.m_y);
61  max_x = std::max(max_x, max.m_x);
62  max_y = std::max(max_y, max.m_y);
63  }
64  PixelCoordinate max(max_x, max_y);
65  PixelCoordinate min(min_x, min_y);
67 
68 
69  // FIXME temporary, for now just enlarge the area by a fixed amount of pixels
70  PixelCoordinate border = (max - min) * .8 + PixelCoordinate(2, 2);
71 
72  min -= border;
73  max += border;
74 
75  // clip to image size
76  min.m_x = std::max(min.m_x, 0);
77  min.m_y = std::max(min.m_y, 0);
78  max.m_x = std::min(max.m_x, subtracted_image->getWidth() - 1);
79  max.m_y = std::min(max.m_y, subtracted_image->getHeight() - 1);
80 
81  // create the image stamp
82  auto width = max.m_x - min.m_x +1;
83  auto height = max.m_y - min.m_y + 1;
84 
85  std::vector<DetectionImage::PixelType> data (width * height);
86  std::vector<DetectionImage::PixelType> thresholded_data (width * height);
87  std::vector<DetectionImage::PixelType> variance_data (width * height);
88 
89  // copy the data
90  for (auto x = min.m_x; x <= max.m_x; ++x) {
91  for (auto y = min.m_y; y <= max.m_y; ++y) {
92  auto index = (x-min.m_x) + (y-min.m_y) * width;
93  data[index] = subtracted_image->getValue(x, y);
94  thresholded_data[index] = thresholded_image->getValue(x, y);
95  variance_data[index] = variance_map->getValue(x, y);
96  }
97  }
98 
99  // set the property
101  std::shared_ptr<DetectionImage> thresholded_stamp =
102  VectorImage<DetectionImage::PixelType>::create(width, height, thresholded_data);
103  std::shared_ptr<WeightImage> variance_stamp =
104  VectorImage<WeightImage::PixelType>::create(width, height, variance_data);
105 
106  group.setProperty<DetectionFrameGroupStamp>(stamp, thresholded_stamp, min, variance_stamp);
107 }
108 
109 } // SEImplementation namespace
110 
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::DetectionFrame
Definition: DetectionFrame.h:33
SourceXtractor::VectorImage::create
static std::shared_ptr< VectorImage< T > > create(Args &&... args)
Definition: VectorImage.h:89
Image.h
SourceXtractor::DetectionFrameGroupStamp
Definition: DetectionFrameGroupStamp.h:33
std::min
T min(T... args)
SourceXtractor::SourceGroupInterface
Defines the interface used to group sources.
Definition: SourceGroupInterface.h:37
x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
Definition: MoffatModelFittingTask.cpp:93
MultithreadedMeasurement.h
SourceXtractor::DetectionFrameGroupStampTask::computeProperties
virtual void computeProperties(SourceGroupInterface &group) const override
Computes one or more properties for the SourceGroup and/or the Sources it contains.
Definition: DetectionFrameGroupStampTask.cpp:39
SourceXtractor::SourceGroupInterface::cbegin
virtual const_iterator cbegin()=0
DetectionFrameGroupStampTask.h
std::max
T max(T... args)
y
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Definition: MoffatModelFittingTask.cpp:93
DetectionFrameGroupStamp.h