InsightSoftwareConsortium / InsightSoftwareConsortium/ITK

wrong centroid values appear randomly between different excecution of the same input

Open
#2,079 4 comments 0 reactions 0 assignees View on GitHub
status:Use_Milestone_Backlog
Dominant language
C++
Stars
1.7k
Forks
748
Avg merge
1d 1h
Merged PRs (30d)
64

Description

https://github.com/InsightSoftwareConsortium/ITK/blob/2b92d3973c18526f4c82965ef3dc286e7a685c6f/Modules/Filtering/LabelMap/include/itkShapeLabelMapFilter.hxx#L100

the calculation of the centroid in 2D image sometimes returns invalid numbers in different runs of the same input. For example: centroid[0] -> 7.52629e+011, centroid[1] -> 128.121

I have tried to calculate the centroid for the same label object by explicitly extracting the points from the label object in the following code:

` for (lit = lineContainer.begin(); lit != lineContainer.end(); lit++)
{
const LabelMapType::IndexType & firstIdx = lit->GetIndex();
const unsigned long & length = lit->GetLength();
long endIdx0 = firstIdx[0] + length;
for (LabelMapType::IndexType idx = firstIdx; idx[0] < endIdx0; ++idx[0])
{
dataX.push_back(idx[0]);
dataY.push_back(idx[1]);
}
}`

this results in the valid numbers: centroid[0] -> 239.448 centroid[1] -> 127.775

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.