SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
PixelCentroidTask.cpp
Go to the documentation of this file.
1
22
27
29
30namespace 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 values of a Source's pixels in the detection image. They are returned as a vector in the same ord...
The bounding box of all the pixels in the source. Both min and max coordinate are inclusive.
void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
The centroid of all the pixels in the source, weighted by their DetectionImage pixel values.
const std::vector< PixelCoordinate > & getCoordinateList() const
The SourceInterface is an abstract "source" that has properties attached to it.
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
SeFloat32 SeFloat
Definition Types.h:32