@@ -100,8 +100,11 @@ class ITK_TEMPLATE_EXPORT CoocurrenceTextureFeaturesImageFilter:public ImageToIm
100100
101101 typedef TInputImage InputImageType;
102102 typedef TOutputImage OutputImageType;
103+ typedef TInputImage MaskImageType;
104+ typedef TInputImage DigitalisedImageType;
103105
104106 typedef typename InputImageType::PixelType PixelType;
107+ typedef typename MaskImageType::PixelType MaskPixelType;
105108 typedef typename InputImageType::IndexType IndexType;
106109 typedef typename InputImageType::PointType PointType;
107110
@@ -226,7 +229,8 @@ class ITK_TEMPLATE_EXPORT CoocurrenceTextureFeaturesImageFilter:public ImageToIm
226229 virtual void UpdateOutputInformation () ITK_OVERRIDE;
227230
228231private:
229- typename InputImageType::Pointer m_DigitalisedInputImageg;
232+ typename DigitalisedImageType::Pointer m_DigitalisedInputImageg;
233+
230234 NeighborhoodRadiusType m_NeighborhoodRadius;
231235 OffsetVectorPointer m_Offsets;
232236 unsigned int m_NumberOfBinsPerAxis;
@@ -236,6 +240,62 @@ class ITK_TEMPLATE_EXPORT CoocurrenceTextureFeaturesImageFilter:public ImageToIm
236240 typename TInputImage::SpacingType m_Spacing;
237241 bool m_Normalize;
238242
243+
244+ struct PreProcessingFunctor
245+ {
246+ PreProcessingFunctor ()
247+ : m_NumberOfBinsPerAxis(256 ),
248+ m_MaskValue (1 ),
249+ m_Min(NumericTraits<PixelType>::min()),
250+ m_Max(NumericTraits<PixelType>::max()){}
251+
252+ PreProcessingFunctor (unsigned int numberOfBinsPerAxis,
253+ PixelType maskValue,
254+ PixelType min,
255+ PixelType max)
256+ : m_NumberOfBinsPerAxis(numberOfBinsPerAxis),
257+ m_MaskValue(maskValue),
258+ m_Min(min),
259+ m_Max(max){}
260+
261+ ~PreProcessingFunctor () {}
262+
263+ bool operator !=(const PreProcessingFunctor& other) const
264+ {
265+ return (m_NumberOfBinsPerAxis != other.m_NumberOfBinsPerAxis )
266+ || (m_MaskValue != other.m_MaskValue )
267+ || (m_Min != other.m_Min )
268+ || (m_Max != other.m_Max );
269+ }
270+
271+ bool operator ==(const PreProcessingFunctor & other) const
272+ {
273+ return !( *this != other );
274+ }
275+
276+ inline typename DigitalisedImageType::PixelType operator ()(const MaskPixelType & maskPixel,
277+ const PixelType & inputPixel) const
278+ {
279+ if (maskPixel != m_MaskValue)
280+ {
281+ return this ->m_Min - 10 ;
282+ }
283+ else if (inputPixel < this ->m_Min || inputPixel >= m_Max)
284+ {
285+ return m_Min - 1 ;
286+ }
287+ else
288+ {
289+ return (inputPixel - m_Min)/((m_Max-m_Min)/ (float )m_NumberOfBinsPerAxis);
290+ }
291+ }
292+
293+ unsigned int m_NumberOfBinsPerAxis;
294+
295+ PixelType m_MaskValue;
296+ PixelType m_Min;
297+ PixelType m_Max;
298+ };
239299};
240300} // end of namespace Statistics
241301} // end of namespace itk
0 commit comments