SourceXtractorPlusPlus  0.12
Please provide a description of the project.
PixelCentroidTask.cpp
Go to the documentation of this file.
1 
27 
29 
30 namespace SourceXtractor {
31 
33  const auto& pixel_values = source.getProperty<DetectionFramePixelValues>().getFilteredValues();
34  const auto& min_coord = source.getProperty<PixelBoundaries>().getMin();
35 
36  double centroid_x = 0.0;
37  double centroid_y = 0.0;
38  double total_value = 0.0;
39 
40  auto i = pixel_values.begin();
41  for (auto pixel_coord : source.getProperty<PixelCoordinateList>().getCoordinateList()) {
42  pixel_coord -= min_coord;
43  SeFloat value = *i++;
44 
45  total_value += value;
46  centroid_x += pixel_coord.m_x * value;
47  centroid_y += pixel_coord.m_y * value;
48  }
49 
50  centroid_x /= total_value;
51  centroid_y /= total_value;
52 
53  source.setProperty<PixelCentroid>(centroid_x + min_coord.m_x, centroid_y + min_coord.m_y);
54 }
55 
56 }
57 
The bounding box of all the pixels in the source. Both min and max coordinate are inclusive...
SeFloat32 SeFloat
Definition: Types.h:32
The centroid of all the pixels in the source, weighted by their DetectionImage pixel values...
Definition: PixelCentroid.h:37
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
The values of a Source&#39;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