SourceXtractorPlusPlus  0.10
Please provide a description of the project.
BoundaryFlagSourceTask.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_BOUNDARYFLAGSOURCETASK_H_
40 #define _SEIMPLEMENTATION_PLUGIN_BOUNDARYFLAGSOURCETASK_H_
41 
46 
47 namespace SourceXtractor {
48 
50 public:
51 
52  BoundaryFlagSourceTask(unsigned instance): m_instance{instance} {}
53 
54  virtual ~BoundaryFlagSourceTask() = default;
55 
56  virtual void computeProperties(SourceInterface &source) const {
57  bool boundary_flag = false;
58 
59  // get the image dimensions
60  auto measurement_frame = source.getProperty<MeasurementFrame>(m_instance).getFrame();
61  auto x_border = measurement_frame->getOriginalImage()->getWidth() - 1;
62  auto y_border = measurement_frame->getOriginalImage()->getHeight() - 1;
63 
64  // iterate over all pixel coordinates
65  auto measurement_rectangle = source.getProperty<MeasurementFrameRectangle>(m_instance);
66 
67  if (measurement_rectangle.getHeight() && measurement_rectangle.getWidth()) {
68  auto top_left = measurement_rectangle.getTopLeft();
69  auto bottom_right = measurement_rectangle.getBottomRight();
70 
71  if (top_left.m_x <= 0 || top_left.m_y <= 0 || bottom_right.m_x >= x_border || bottom_right.m_y >= y_border) {
72  boundary_flag = true;
73  }
74  }
75 
77  };
78 
79 private:
80  unsigned m_instance;
81 }; // End of BoundaryFlagSourceTask class
82 
83 } // namespace SourceXtractor
84 
85 #endif /* _SEIMPLEMENTATION_PLUGIN_BOUNDARYFLAGSOURCETASK_H_ */
86 
87 
88 
SourceXtractor::BoundaryFlag
Definition: BoundaryFlag.h:46
MeasurementFrame.h
SourceXtractor::boundary_flag
static StaticPlugin< BoundaryFlagPlugin > boundary_flag
Definition: BoundaryFlagPlugin.cpp:43
SourceXtractor::MeasurementFrameRectangle
Definition: MeasurementFrameRectangle.h:33
SourceXtractor
Definition: Aperture.h:30
BoundaryFlag.h
SourceXtractor::BoundaryFlagSourceTask::computeProperties
virtual void computeProperties(SourceInterface &source) const
Computes one or more properties for the Source.
Definition: BoundaryFlagSourceTask.h:56
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::MeasurementFrame
Definition: MeasurementFrame.h:36
SourceXtractor::BoundaryFlagSourceTask::m_instance
unsigned m_instance
Definition: BoundaryFlagSourceTask.h:77
SourceXtractor::BoundaryFlagSourceTask::BoundaryFlagSourceTask
BoundaryFlagSourceTask(unsigned instance)
Definition: BoundaryFlagSourceTask.h:52
SourceXtractor::BoundaryFlagSourceTask
Definition: BoundaryFlagSourceTask.h:49
SourceXtractor::SourceTask
A Task that acts on a Source to compute one or more properties.
Definition: SourceTask.h:36
SourceXtractor::BoundaryFlagSourceTask::~BoundaryFlagSourceTask
virtual ~BoundaryFlagSourceTask()=default
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::MeasurementFrameRectangle::getTopLeft
PixelCoordinate getTopLeft() const
Definition: MeasurementFrameRectangle.h:45
SourceXtractor::SourceInterface
The SourceInterface is an abstract "source" that has properties attached to it.
Definition: SourceInterface.h:46
MeasurementFrameRectangle.h
SourceTask.h