17 #ifndef __itkLabelStatisticsImageFilter_h
18 #define __itkLabelStatisticsImageFilter_h
21 #include "itkNumericTraits.h"
54 template<
class TInputImage,
class TLabelImage>
74 typedef typename TInputImage::SizeType
SizeType;
87 itkStaticConstMacro(ImageDimension,
unsigned int,
88 TInputImage::ImageDimension );
91 typedef typename NumericTraits<PixelType>::RealType
RealType;
103 #ifdef ITK_USE_REVIEW_STATISTICS
122 m_Sum = NumericTraits<RealType>::Zero;
123 m_SumOfSquares = NumericTraits<RealType>::Zero;
126 m_Minimum = NumericTraits<RealType>::max();
127 m_Maximum = NumericTraits<RealType>::NonpositiveMin();
130 m_Mean = NumericTraits<RealType>::Zero;
131 m_Sigma = NumericTraits<RealType>::Zero;
132 m_Variance = NumericTraits<RealType>::Zero;
134 unsigned int imageDimension = itkGetStaticConstMacro(ImageDimension);
135 m_BoundingBox.resize(imageDimension*2);
136 for (
unsigned int i = 0; i < imageDimension * 2; i += 2)
138 m_BoundingBox[i] = NumericTraits<ITK_TYPENAME IndexType::IndexValueType>::max();
139 m_BoundingBox[i+1] = NumericTraits<ITK_TYPENAME IndexType::IndexValueType>::NonpositiveMin();
151 m_Sum = NumericTraits<RealType>::Zero;
152 m_SumOfSquares = NumericTraits<RealType>::Zero;
155 m_Minimum = NumericTraits<RealType>::max();
156 m_Maximum = NumericTraits<RealType>::NonpositiveMin();
159 m_Mean = NumericTraits<RealType>::Zero;
160 m_Sigma = NumericTraits<RealType>::Zero;
161 m_Variance = NumericTraits<RealType>::Zero;
163 unsigned int imageDimension = itkGetStaticConstMacro(ImageDimension);
164 m_BoundingBox.resize(imageDimension*2);
165 for (
unsigned int i = 0; i < imageDimension * 2; i += 2)
167 m_BoundingBox[i] = NumericTraits<ITK_TYPENAME IndexType::IndexValueType>::max();
168 m_BoundingBox[i+1] = NumericTraits<ITK_TYPENAME IndexType::IndexValueType>::NonpositiveMin();
172 m_Histogram = HistogramType::New();
176 #ifdef ITK_USE_REVIEW_STATISTICS
180 m_Histogram->SetMeasurementVectorSize(1);
185 m_Histogram->Initialize(hsize, lb, ub);
236 itkSetMacro(UseHistograms,
bool);
237 itkGetConstMacro(UseHistograms,
bool);
238 itkBooleanMacro(UseHistograms);
241 void SetLabelInput(
const TLabelImage *input)
244 this->SetNthInput(1, const_cast<TLabelImage *>(input) );
257 return m_LabelStatistics.find(label) != m_LabelStatistics.end();
261 unsigned long GetNumberOfObjects()
const
263 return m_LabelStatistics.size();
265 unsigned long GetNumberOfLabels()
const
267 return this->GetNumberOfObjects();
272 RealType GetMinimum(LabelPixelType label)
const;
275 RealType GetMaximum(LabelPixelType label)
const;
278 RealType GetMean(LabelPixelType label)
const;
281 RealType GetMedian(LabelPixelType label)
const;
284 RealType GetSigma(LabelPixelType label)
const;
287 RealType GetVariance(LabelPixelType label)
const;
290 BoundingBoxType GetBoundingBox(LabelPixelType label)
const;
293 RegionType GetRegion(LabelPixelType label)
const;
296 RealType GetSum(LabelPixelType label)
const;
299 unsigned long GetCount(LabelPixelType label)
const;
302 HistogramPointer GetHistogram(LabelPixelType label)
const;
305 void SetHistogramParameters(
const int numBins, RealType lowerBound,
306 RealType upperBound);
308 #ifdef ITK_USE_CONCEPT_CHECKING
318 void PrintSelf(std::ostream& os,
Indent indent)
const;
321 void AllocateOutputs();
324 void BeforeThreadedGenerateData ();
327 void AfterThreadedGenerateData ();
330 void ThreadedGenerateData (
const RegionType&
331 outputRegionForThread,
335 void GenerateInputRequestedRegion();
338 void EnlargeOutputRequestedRegion(
DataObject *data);
343 void operator=(
const Self&);
358 #ifndef ITK_MANUAL_INSTANTIATION