SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SaturateFlagSourceTask.h
Go to the documentation of this file.
1
17/*
18 * Copyright (C) 2012-2020 Euclid Science Ground Segment
19 *
20 * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
21 * Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option)
22 * any later version.
23 *
24 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
25 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
26 * details.
27 *
28 * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to
29 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30 */
31
38
39#ifndef _SEIMPLEMENTATION_PLUGIN_ATURATEFLAGSOURCETASK_H_
40#define _SEIMPLEMENTATION_PLUGIN_ATURATEFLAGSOURCETASK_H_
41
44
49
51
52namespace SourceXtractor {
53
55public:
56 explicit SaturateFlagSourceTask(unsigned instance): m_instance{instance} {}
57
58 virtual ~SaturateFlagSourceTask() = default;
59
60 virtual void computeProperties(SourceInterface &source) const {
61 bool saturate_flag = false;
62
63 const auto& measurement_frame_info = source.getProperty<MeasurementFrameInfo>(m_instance);
64 const auto& measurement_frame_images = source.getProperty<MeasurementFrameImages>(m_instance);
65
66 const auto saturation = measurement_frame_info.getSaturation();
67 const auto measurement_rectangle = source.getProperty<MeasurementFrameRectangle>(m_instance);
68
69 if (saturation > 0 && measurement_rectangle.getWidth()) {
70 // iterate over all pixel values
71 auto stamp = measurement_frame_images.getImageChunk(LayerOriginalImage,
72 measurement_rectangle.getTopLeft().m_x, measurement_rectangle.getTopLeft().m_y,
73 measurement_rectangle.getWidth(), measurement_rectangle.getHeight());
74
75 for (int y = 0; y < stamp->getHeight(); ++y) {
76 for (int x = 0; x < stamp->getWidth(); ++x) {
77 if (stamp->getValue(x, y) >= saturation) {
78 saturate_flag = true;
79 break;
80 }
81 }
82 }
83 }
84
85 // set the property
87 };
88private:
89 unsigned m_instance;
90
91}; // End of SaturateFlagSourceTask class
92
93} // namespace SourceXtractor
94
95#endif /* _SEIMPLEMENTATION_PLUGIN_ATURATEFLAGSOURCETASK_H_ */
96
97
98
virtual void computeProperties(SourceInterface &source) const
Computes one or more properties for the Source.
The SourceInterface is an abstract "source" that has properties attached to it.
void setIndexedProperty(std::size_t index, Args... args)
Convenience template method to call setProperty() with a more user-friendly syntax.
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
A Task that acts on a Source to compute one or more properties.
Definition SourceTask.h:36
@ LayerOriginalImage
Definition Frame.h:37
static StaticPlugin< SaturateFlagPlugin > saturate_flag