Skip to content

Commit 1d7adc7

Browse files
committed
BUG: Avoid histogram range overflow
fixes #71
1 parent 6d00b70 commit 1d7adc7

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

include/itkCoocurrenceTextureFeaturesImageFilter.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ namespace Statistics
7373
* intensity range. For example they could be the minimum and maximum intensity of the image, or 0 and
7474
* the maximum intensity (if the negative values are considered as noise).
7575
*
76+
* WARNING: This probably won't work for pixels of double or long-double type
77+
* unless you set the histogram min and max manually. This is because the largest
78+
* histogram bin by default has max value of the largest possible pixel value
79+
* plus 1. For double and long-double types, whose "RealType" as defined by the
80+
* NumericTraits class is the same, and thus cannot hold any larger values,
81+
* this would cause a float overflow.
82+
*
7683
* \sa HistogramToTextureFeaturesFilter
7784
* \sa ScalarImageToCooccurrenceMatrixFilte
7885
* \sa ScalarImageToTextureFeaturesFilter

include/itkDigitizerFunctor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ class Digitizer
8585

8686
MaskPixelType m_MaskValue;
8787

88-
PixelType m_Min;
89-
PixelType m_Max;
88+
typename NumericTraits<PixelType>::RealType m_Min;
89+
typename NumericTraits<PixelType>::RealType m_Max;
9090
};
9191

9292
}

include/itkRunLengthTextureFeaturesImageFilter.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ namespace Statistics
8686
* -# Distance range: For better results the distance range should be adapted to the spacing of the input image
8787
* and the size of the neighborhood.
8888
*
89+
* WARNING: This probably won't work for pixels of double or long-double type
90+
* unless you set the histogram min and max manually. This is because the largest
91+
* histogram bin by default has max value of the largest possible pixel value
92+
* plus 1. For double and long-double types, whose "RealType" as defined by the
93+
* NumericTraits class is the same, and thus cannot hold any larger values,
94+
* this would cause a float overflow.
95+
*
8996
* \sa ScalarImageToRunLengthFeaturesFilter
9097
* \sa ScalarImageToRunLengthMatrixFilter
9198
* \sa HistogramToRunLengthFeaturesFilter

0 commit comments

Comments
 (0)