SourceXtractorPlusPlus  0.10
Please provide a description of the project.
PixelBoundariesTask.cpp
Go to the documentation of this file.
1 
23 #include <climits>
24 
30 
31 namespace SourceXtractor {
32 
34  int min_x = INT_MAX;
35  int min_y = INT_MAX;
36  int max_x = INT_MIN;
37  int max_y = INT_MIN;
38 
39  for (auto pixel_coord : source.getProperty<PixelCoordinateList>().getCoordinateList()) {
40  min_x = std::min(min_x, pixel_coord.m_x);
41  min_y = std::min(min_y, pixel_coord.m_y);
42  max_x = std::max(max_x, pixel_coord.m_x);
43  max_y = std::max(max_y, pixel_coord.m_y);
44  }
45 
46  source.setProperty<PixelBoundaries>(min_x, min_y, max_x, max_y);
47 }
48 
50  const auto& pixel_values = source.getProperty<DetectionFramePixelValues>().getFilteredValues();
51  SeFloat half_maximum = source.getProperty<PeakValue>().getMaxValue() / 2.0;
52 
53  int min_x_half = INT_MAX;
54  int min_y_half = INT_MAX;
55  int max_x_half = INT_MIN;
56  int max_y_half = INT_MIN;
57 
58  auto i = pixel_values.begin();
59  for (auto pixel_coord : source.getProperty<PixelCoordinateList>().getCoordinateList()) {
60  SeFloat value = *i++;
61 
62  if (value >= half_maximum) {
63  min_x_half = std::min(min_x_half, pixel_coord.m_x);
64  min_y_half = std::min(min_y_half, pixel_coord.m_y);
65  max_x_half = std::max(max_x_half, pixel_coord.m_x);
66  max_y_half = std::max(max_y_half, pixel_coord.m_y);
67  }
68  }
69 
70  source.setProperty<PixelBoundariesHalfMaximum>(min_x_half, min_y_half, max_x_half, max_y_half);
71 }
72 
73 } // SEImplementation namespace
74 
The bounding box of all the pixels in the source. Both min and max coordinate are inclusive.
SeFloat32 SeFloat
Definition: Types.h:32
T min(T... args)
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
virtual void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
T max(T... args)
The values of a Source's pixels in the detection image. They are returned as a vector in the same ord...
virtual void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
The SourceInterface is an abstract "source" that has properties attached to it.
const std::vector< PixelCoordinate > & getCoordinateList() const