Skip to content

BUG: Fix computation of weighted centroid in LabelGeometryImageFilter#4530

Merged
dzenanz merged 2 commits intoInsightSoftwareConsortium:masterfrom
dzenanz:weightedCentroid
Mar 20, 2024
Merged

BUG: Fix computation of weighted centroid in LabelGeometryImageFilter#4530
dzenanz merged 2 commits intoInsightSoftwareConsortium:masterfrom
dzenanz:weightedCentroid

Conversation

@dzenanz
Copy link
Member

@dzenanz dzenanz commented Mar 20, 2024

Intensity values were cast to integers, thus making the computation imprecise.

Images below show centroids in red and weighted centroids in green.

Before this PR:
centroidsOld

After this PR:
centroidsNew

PR Checklist

Intensity values were cast to integers,
thus making the computation imprecise.
@github-actions github-actions bot added the type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances label Mar 20, 2024
@blowekamp
Copy link
Member

The changes look OK.

Just an FYI, not all attributes of LabelGeometryImageFilter take into consideration image spacing and geometry. The similar LabelMap based statistics I have found to be reliable.

@dzenanz
Copy link
Member Author

dzenanz commented Mar 20, 2024

The above used image has unit spacing, so that is not the issue.

Use real-typed variable for the accumulation.
@dzenanz dzenanz merged commit 8ceefec into InsightSoftwareConsortium:master Mar 20, 2024
@dzenanz dzenanz deleted the weightedCentroid branch March 20, 2024 19:56
dzenanz added a commit to dzenanz/ITK that referenced this pull request Apr 29, 2024
This filter is buggy, and sometimes produces wrong results. Follow-up to:
InsightSoftwareConsortium#4530
dzenanz added a commit to dzenanz/ITK that referenced this pull request Apr 29, 2024
This filter is buggy, and sometimes produces wrong results. Follow-up to:
InsightSoftwareConsortium#4530
dzenanz added a commit that referenced this pull request Apr 29, 2024
This filter is buggy, and sometimes produces wrong results. Follow-up to:
#4530
bourdaisj pushed a commit to bourdaisj/ITK that referenced this pull request May 15, 2024
This filter is buggy, and sometimes produces wrong results. Follow-up to:
InsightSoftwareConsortium#4530
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants