SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
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
26
29
32
33
34namespace SourceXtractor {
35
37 // we are obviously assuming the same DetectionFrameImages for all sources
38 auto detection_frame_images = group.cbegin()->getProperty<DetectionFrameImages>();
39
41 int min_x = INT_MAX;
42 int min_y = INT_MAX;
43 int max_x = INT_MIN;
44 int max_y = INT_MIN;
45
46 for (auto& source : group) {
47 const auto& boundaries = source.getProperty<PixelBoundaries>();
48 const auto& min = boundaries.getMin();
49 const auto& max = boundaries.getMax();
50
51 min_x = std::min(min_x, min.m_x);
52 min_y = std::min(min_y, min.m_y);
53 max_x = std::max(max_x, max.m_x);
54 max_y = std::max(max_y, max.m_y);
55 }
56 PixelCoordinate max(max_x, max_y);
57 PixelCoordinate min(min_x, min_y);
59
60
61 // FIXME temporary, for now just enlarge the area by a fixed amount of pixels
62 PixelCoordinate border = (max - min) * .8 + PixelCoordinate(2, 2);
63
64 min -= border;
65 max += border;
66
67 // clip to image size
68 min.m_x = std::max(min.m_x, 0);
69 min.m_y = std::max(min.m_y, 0);
70 max.m_x = std::min(max.m_x, detection_frame_images.getWidth() - 1);
71 max.m_y = std::min(max.m_y, detection_frame_images.getHeight() - 1);
72
73 // create the image stamp
74 auto width = max.m_x - min.m_x +1;
75 auto height = max.m_y - min.m_y + 1;
76
78 *detection_frame_images.getImageChunk(LayerSubtractedImage, min.m_x, min.m_y, width, height));
80 *detection_frame_images.getImageChunk(LayerThresholdedImage, min.m_x, min.m_y, width, height));
82 *detection_frame_images.getImageChunk(LayerVarianceMap, min.m_x, min.m_y, width, height));
83
84
85 group.setProperty<DetectionFrameGroupStamp>(stamp, thresholded_stamp, min, variance_stamp);
86}
87
88} // SEImplementation namespace
89
void computeProperties(SourceGroupInterface &group) const override
Computes one or more properties for the SourceGroup and/or the Sources it contains.
The bounding box of all the pixels in the source. Both min and max coordinate are inclusive.
Defines the interface used to group sources.
virtual const_iterator cbegin() const =0
static std::shared_ptr< VectorImage< T > > create(Args &&... args)
T max(T... args)
T min(T... args)
@ LayerVarianceMap
Definition Frame.h:45
@ LayerThresholdedImage
Definition Frame.h:41
@ LayerSubtractedImage
Definition Frame.h:39
A pixel coordinate made of two integers m_x and m_y.