SourceXtractorPlusPlus  0.15
Please provide a description of the project.
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 
44 
49 
51 
52 namespace SourceXtractor {
53 
55 public:
56  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  };
88 private:
89  unsigned m_instance;
90 
91 }; // End of SaturateFlagSourceTask class
92 
93 } // namespace SourceXtractor
94 
95 #endif /* _SEIMPLEMENTATION_PLUGIN_ATURATEFLAGSOURCETASK_H_ */
96 
97 
98 
SourceXtractor::LayerOriginalImage
@ LayerOriginalImage
Definition: Frame.h:36
SourceXtractor::SaturateFlagSourceTask::~SaturateFlagSourceTask
virtual ~SaturateFlagSourceTask()=default
MeasurementFrameInfo.h
SourceXtractor::SaturateFlagSourceTask
Definition: SaturateFlagSourceTask.h:54
SourceXtractor::MeasurementFrameImages::getWidth
int getWidth() const
Definition: MeasurementFrameImages.h:47
SourceXtractor::SaturateFlagSourceTask::computeProperties
virtual void computeProperties(SourceInterface &source) const
Computes one or more properties for the Source.
Definition: SaturateFlagSourceTask.h:60
SourceXtractor::MeasurementFrameRectangle
Definition: MeasurementFrameRectangle.h:33
DetectionFrame.h
DetectionFramePixelValues.h
SourceXtractor::MeasurementFrameImages
Definition: MeasurementFrameImages.h:31
SourceXtractor
Definition: Aperture.h:30
SourceXtractor::SaturateFlagSourceTask::m_instance
unsigned m_instance
Definition: SaturateFlagSourceTask.h:87
SourceXtractor::MeasurementFrameInfo
Definition: MeasurementFrameInfo.h:28
SourceXtractor::SourceInterface::setIndexedProperty
void setIndexedProperty(std::size_t index, Args... args)
Convenience template method to call setProperty() with a more user-friendly syntax.
Definition: SourceInterface.h:64
SourceXtractor::saturate_flag
static StaticPlugin< SaturateFlagPlugin > saturate_flag
Definition: SaturateFlagPlugin.cpp:43
SaturateFlag.h
SourceXtractor::SaturateFlag
Definition: SaturateFlag.h:46
x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
Definition: MoffatModelFittingTask.cpp:94
SourceXtractor::SourceTask
A Task that acts on a Source to compute one or more properties.
Definition: SourceTask.h:36
SourceXtractor::SaturateFlagSourceTask::SaturateFlagSourceTask
SaturateFlagSourceTask(unsigned instance)
Definition: SaturateFlagSourceTask.h:56
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
MeasurementFrameRectangle.h
y
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Definition: MoffatModelFittingTask.cpp:94
SourceTask.h
MeasurementFrameImages.h