SourceXtractorPlusPlus
0.15
Please provide a description of the project.
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
SEImplementation
src
lib
Plugin
PixelCentroid
PixelCentroidTask.cpp
Go to the documentation of this file.
1
23
#include "
SEImplementation/Property/PixelCoordinateList.h
"
24
#include "
SEImplementation/Plugin/DetectionFramePixelValues/DetectionFramePixelValues.h
"
25
#include "
SEImplementation/Plugin/PixelCentroid/PixelCentroid.h
"
26
#include "
SEImplementation/Plugin/PixelBoundaries/PixelBoundaries.h
"
27
28
#include "
SEImplementation/Plugin/PixelCentroid/PixelCentroidTask.h
"
29
30
namespace
SourceXtractor {
31
32
void
PixelCentroidTask::computeProperties
(
SourceInterface
& source)
const
{
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
PixelCoordinateList.h
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::PixelBoundaries
The bounding box of all the pixels in the source. Both min and max coordinate are inclusive...
Definition:
PixelBoundaries.h:37
PixelBoundaries.h
SourceXtractor::PixelCoordinateList
Definition:
PixelCoordinateList.h:31
SourceXtractor::SeFloat
SeFloat32 SeFloat
Definition:
Types.h:32
SourceXtractor::PixelCentroid
The centroid of all the pixels in the source, weighted by their DetectionImage pixel values...
Definition:
PixelCentroid.h:37
PixelCentroidTask.h
PixelCentroid.h
SourceXtractor::SourceInterface::setProperty
void setProperty(Args...args)
Definition:
SourceInterface.h:72
DetectionFramePixelValues.h
SourceXtractor::DetectionFramePixelValues
The values of a Source's pixels in the detection image. They are returned as a vector in the same ord...
Definition:
DetectionFramePixelValues.h:39
SourceXtractor::PixelCoordinateList::getCoordinateList
const std::vector< PixelCoordinate > & getCoordinateList() const
Definition:
PixelCoordinateList.h:41
SourceXtractor::PixelCentroidTask::computeProperties
virtual void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
Definition:
PixelCentroidTask.cpp:32
SourceXtractor::SourceInterface
The SourceInterface is an abstract "source" that has properties attached to it.
Definition:
SourceInterface.h:46
Generated by
1.8.5