SourceXtractorPlusPlus  0.10
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
39 #ifndef _SEIMPLEMENTATION_PLUGIN_ATURATEFLAGSOURCETASK_H_
40 #define _SEIMPLEMENTATION_PLUGIN_ATURATEFLAGSOURCETASK_H_
41 
49 
50 namespace SourceXtractor {
51 
53 public:
54  SaturateFlagSourceTask(unsigned instance): m_instance{instance} {}
55 
56  virtual ~SaturateFlagSourceTask() = default;
57 
58  virtual void computeProperties(SourceInterface &source) const {
60 
61  bool saturate_flag = false;
62 
63  const auto measurement_frame = source.getProperty<MeasurementFrame>(m_instance).getFrame();
64  const auto saturation = measurement_frame->getSaturation();
65  const auto measurement_rectangle = source.getProperty<MeasurementFrameRectangle>(m_instance);
66 
67  if (saturation > 0 && measurement_rectangle.getWidth()) {
68  // iterate over all pixel values
69  auto image = measurement_frame->getOriginalImage();
70  auto stamp = image->getChunk(
71  measurement_rectangle.getTopLeft().m_x, measurement_rectangle.getTopLeft().m_y,
72  measurement_rectangle.getWidth(), measurement_rectangle.getHeight());
73 
74  for (int y = 0; y < stamp->getHeight(); ++y) {
75  for (int x = 0; x < stamp->getWidth(); ++x) {
76  if (stamp->getValue(x, y) >= saturation) {
77  saturate_flag = true;
78  break;
79  }
80  }
81  }
82  }
83 
84  // set the property
86  };
87 private:
88  unsigned m_instance;
89 
90 }; // End of SaturateFlagSourceTask class
91 
92 } // namespace SourceXtractor
93 
94 #endif /* _SEIMPLEMENTATION_PLUGIN_ATURATEFLAGSOURCETASK_H_ */
95 
96 
97 
static StaticPlugin< SaturateFlagPlugin > saturate_flag
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
void setIndexedProperty(std::size_t index, Args...args)
Convenience template method to call setProperty() with a more user-friendly syntax.
A Task that acts on a Source to compute one or more properties.
Definition: SourceTask.h:36
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
T lock(T...args)
virtual void computeProperties(SourceInterface &source) const
Computes one or more properties for the Source.
The SourceInterface is an abstract &quot;source&quot; that has properties attached to it.