00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkStatisticsImageFilter_h
00018 #define __itkStatisticsImageFilter_h
00019
00020 #include "itkImageToImageFilter.h"
00021 #include "itkNumericTraits.h"
00022 #include "itkArray.h"
00023 #include "itkSimpleDataObjectDecorator.h"
00024
00025
00026 namespace itk {
00027
00043 template<class TInputImage>
00044 class ITK_EXPORT StatisticsImageFilter :
00045 public ImageToImageFilter<TInputImage, TInputImage>
00046 {
00047 public:
00049 typedef StatisticsImageFilter Self;
00050 typedef ImageToImageFilter<TInputImage,TInputImage> Superclass;
00051 typedef SmartPointer<Self> Pointer;
00052 typedef SmartPointer<const Self> ConstPointer;
00053
00055 itkNewMacro(Self);
00056
00058 itkTypeMacro(StatisticsImageFilter, ImageToImageFilter);
00059
00061 typedef typename TInputImage::Pointer InputImagePointer;
00062
00063 typedef typename TInputImage::RegionType RegionType ;
00064 typedef typename TInputImage::SizeType SizeType ;
00065 typedef typename TInputImage::IndexType IndexType ;
00066 typedef typename TInputImage::PixelType PixelType ;
00067
00069 itkStaticConstMacro(ImageDimension, unsigned int,
00070 TInputImage::ImageDimension ) ;
00071
00073 typedef typename NumericTraits<PixelType>::RealType RealType;
00074
00076 typedef typename DataObject::Pointer DataObjectPointer;
00077
00079 typedef SimpleDataObjectDecorator<RealType> RealObjectType;
00080 typedef SimpleDataObjectDecorator<PixelType> PixelObjectType;
00081
00083 PixelType GetMinimum() const
00084 { return this->GetMinimumOutput()->Get(); }
00085 PixelObjectType* GetMinimumOutput();
00086 const PixelObjectType* GetMinimumOutput() const;
00087
00089 PixelType GetMaximum() const
00090 { return this->GetMaximumOutput()->Get(); }
00091 PixelObjectType* GetMaximumOutput();
00092 const PixelObjectType* GetMaximumOutput() const;
00093
00095 RealType GetMean() const
00096 { return this->GetMeanOutput()->Get(); }
00097 RealObjectType* GetMeanOutput();
00098 const RealObjectType* GetMeanOutput() const;
00099
00101 RealType GetSigma() const
00102 { return this->GetSigmaOutput()->Get(); }
00103 RealObjectType* GetSigmaOutput();
00104 const RealObjectType* GetSigmaOutput() const;
00105
00107 RealType GetVariance() const
00108 { return this->GetVarianceOutput()->Get(); }
00109 RealObjectType* GetVarianceOutput();
00110 const RealObjectType* GetVarianceOutput() const;
00111
00113 RealType GetSum() const
00114 { return this->GetSumOutput()->Get(); }
00115 RealObjectType* GetSumOutput();
00116 const RealObjectType* GetSumOutput() const;
00117
00120 virtual DataObjectPointer MakeOutput(unsigned int idx);
00121
00122 protected:
00123 StatisticsImageFilter();
00124 ~StatisticsImageFilter(){};
00125 void PrintSelf(std::ostream& os, Indent indent) const;
00126
00128 void AllocateOutputs();
00129
00131 void BeforeThreadedGenerateData ();
00132
00134 void AfterThreadedGenerateData ();
00135
00137 void ThreadedGenerateData (const RegionType&
00138 outputRegionForThread,
00139 int threadId) ;
00140
00141
00142 void GenerateInputRequestedRegion();
00143
00144
00145 void EnlargeOutputRequestedRegion(DataObject *data);
00146
00147 private:
00148 StatisticsImageFilter(const Self&);
00149 void operator=(const Self&);
00150
00151 Array<RealType> m_ThreadSum;
00152 Array<RealType> m_SumOfSquares;
00153 Array<long> m_Count;
00154 Array<PixelType> m_ThreadMin;
00155 Array<PixelType> m_ThreadMax;
00156
00157 } ;
00158
00159 }
00160
00161 #ifndef ITK_MANUAL_INSTANTIATION
00162 #include "itkStatisticsImageFilter.txx"
00163 #endif
00164
00165 #endif