Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __itkMeanProjectionImageFilter_h
00019 #define __itkMeanProjectionImageFilter_h
00020
00021 #include "itkProjectionImageFilter.h"
00022 #include "itkNumericTraits.h"
00023 #include "itkConceptChecking.h"
00024
00025 namespace itk {
00047 namespace Function {
00048 template <class TInputPixel, class TAccumulate>
00049 class MeanAccumulator
00050 {
00051 public:
00052 typedef typename NumericTraits<TInputPixel>::RealType RealType;
00053
00054 MeanAccumulator( unsigned long size )
00055 {
00056 m_Size = size;
00057 }
00058 ~MeanAccumulator(){}
00059
00060 inline void Initialize()
00061 {
00062 m_Sum = NumericTraits< TAccumulate >::Zero;
00063 }
00064
00065 inline void operator()( const TInputPixel &input )
00066 {
00067 m_Sum = m_Sum + input;
00068 }
00069
00070 inline RealType GetValue()
00071 {
00072 return ((RealType) m_Sum) / m_Size;
00073 }
00074
00075 TAccumulate m_Sum;
00076 unsigned long m_Size;
00077 };
00078 }
00079
00080
00081 template <class TInputImage, class TOutputImage,
00082 class TAccumulate=
00083 ITK_TYPENAME NumericTraits<
00084 ITK_TYPENAME TOutputImage::PixelType >::AccumulateType >
00085 class ITK_EXPORT MeanProjectionImageFilter : public
00086 ProjectionImageFilter<TInputImage, TOutputImage,
00087 Function::MeanAccumulator< typename TInputImage::PixelType, TAccumulate > >
00088 {
00089 public:
00090 typedef MeanProjectionImageFilter Self;
00091 typedef ProjectionImageFilter<TInputImage, TOutputImage,
00092 Function::MeanAccumulator<
00093 typename TInputImage::PixelType, TAccumulate > > Superclass;
00094
00095 typedef SmartPointer<Self> Pointer;
00096 typedef SmartPointer<const Self> ConstPointer;
00097
00098 typedef TInputImage InputImageType;
00099 typedef typename InputImageType::PixelType InputPixelType;
00100
00101 typedef TOutputImage OutputImageType;
00102 typedef typename OutputImageType::PixelType OutputPixelType;
00103
00105 itkTypeMacro(MeanProjectionImageFilter, ProjectionImageFilter);
00106
00108 itkNewMacro(Self);
00109
00110 #ifdef ITK_USE_CONCEPT_CHECKING
00111
00112 itkConceptMacro(InputPixelToOutputPixelTypeGreaterAdditiveOperatorCheck,
00113 (Concept::AdditiveOperators<OutputPixelType,
00114 InputPixelType,
00115 OutputPixelType>));
00116
00117 itkConceptMacro(InputHasNumericTraitsCheck,
00118 (Concept::HasNumericTraits<InputPixelType>));
00120 #endif
00121
00122
00123 protected:
00124 MeanProjectionImageFilter() {}
00125 virtual ~MeanProjectionImageFilter() {}
00126
00127 private:
00128 MeanProjectionImageFilter(const Self&);
00129 void operator=(const Self&);
00130
00131 };
00132
00133 }
00134
00135 #endif
00136