Page MenuHomePhabricator

mitkImageStatisticsCalculator returns wrong index if the value for min and max are the same
Closed, ResolvedPublic

Description

In the method ImageStatisticsCalculator::InternalCalculateStatisticsMasked the itk::MinimumMaximumImageFilter is used to get the index values for min and max. This filter only determines the min and max of an input image, without a mask (so min and max of the complete image).

To be able to get the min and max index values in dependence to the mask an image is created (using the itk::MaskImageFilter) where the values outside the segmentation are set to a value which is between the min and max value:

outsideValue = (min + max)/2

In the case where min and max are the same this would lead to an image where ALL voxel values are the same and the first index is taken. This then would be wrong!

The whole approach is in my opinion not very nice and hard to understand when first looking at it. The itk::LabelStatisticsImageFilter used for the actual statistics calculation unfortunately does not provide the index for the max and min values. This should be easily changeable in the itk::LabelStatisticsImageFilter (I haven't looked at the actual code of the filter yet) and the workaround implemented here is way to complicated. Also this would save time because the statistics have already been calculated and it seems like a waste to create another image and calculate again the max and min values just to get the index values.

Event Timeline

For now I will implement a workaround to be able to calculate the correct index if min and max have the same value. I still think that (at least) this part should be refactored: T17963

User dsaruji has pushed new remote branch:

bug-17962-wrong-index-if-min-and-max-have-same-value

User dsaruji has pushed new remote branch:

bug-17962-wrong-index-statistics-based-on-master

(In reply to Git Admin from comment #3)

User dsaruji has pushed new remote branch:

bug-17962-wrong-index-statistics-based-on-master

Branch for master

[c825b9]: Merge branch 'bug-17962-wrong-index-statistics-based-on-master'

Merged commits:

2014-07-29 15:48:08 Danial Saruji [5c5463]
calculate correct min and max index if values are the same

Workaround to fix here mentioned input has been implemented. Follow-up ticket created for refactoring: T17963

(In reply to Danial Saruji from comment #6)

Workaround to fix here mentioned input has been implemented. Follow-up
ticket created for refactoring: T17963

correction in comment: "issue" instead of "input"