ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkMeanProjectionImageFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkMeanProjectionImageFilter_h
00019 #define __itkMeanProjectionImageFilter_h
00020 
00021 #include "itkProjectionImageFilter.h"
00022 #include "itkConceptChecking.h"
00023 
00024 namespace itk
00025 {
00047 namespace Functor
00048 {
00049 template< class TInputPixel, class TAccumulate >
00050 class MeanAccumulator
00051 {
00052 public:
00053   typedef typename NumericTraits< TInputPixel >::RealType       RealType;
00054 
00055   MeanAccumulator( SizeValueType size )
00056   {
00057     m_Size = size;
00058   }
00059 
00060   ~MeanAccumulator()
00061   {
00062     m_Size = NumericTraits< SizeValueType >::Zero;
00063   }
00064 
00065   inline void Initialize()
00066   {
00067     m_Sum = NumericTraits< TAccumulate >::Zero;
00068   }
00069 
00070   inline void operator()(const TInputPixel & input)
00071   {
00072     m_Sum = m_Sum + input;
00073   }
00074 
00075   inline RealType GetValue()
00076   {
00077     return ( (RealType)m_Sum ) / m_Size;
00078   }
00079 
00080   TAccumulate   m_Sum;
00081   SizeValueType m_Size;
00082 };
00083 } // end namespace Function
00084 
00085 template< class TInputImage, class TOutputImage,
00086           class TAccumulate =
00087             typename NumericTraits<
00088               typename TOutputImage::PixelType >::AccumulateType >
00089 class ITK_EXPORT MeanProjectionImageFilter:public
00090   ProjectionImageFilter< TInputImage, TOutputImage,
00091                          Functor::MeanAccumulator< typename TInputImage::PixelType, TAccumulate > >
00092 {
00093 public:
00094   typedef MeanProjectionImageFilter Self;
00095   typedef ProjectionImageFilter< TInputImage, TOutputImage,
00096                                  Functor::MeanAccumulator<
00097                                    typename TInputImage::PixelType, TAccumulate > > Superclass;
00098 
00099   typedef SmartPointer< Self >       Pointer;
00100   typedef SmartPointer< const Self > ConstPointer;
00101 
00102   typedef TInputImage                        InputImageType;
00103   typedef typename InputImageType::PixelType InputPixelType;
00104 
00105   typedef TOutputImage                        OutputImageType;
00106   typedef typename OutputImageType::PixelType OutputPixelType;
00107 
00109   itkTypeMacro(MeanProjectionImageFilter, ProjectionImageFilter);
00110 
00112   itkNewMacro(Self);
00113 
00114 #ifdef ITK_USE_CONCEPT_CHECKING
00115 
00116   itkConceptMacro( InputPixelToOutputPixelTypeGreaterAdditiveOperatorCheck,
00117                    ( Concept::AdditiveOperators< OutputPixelType,
00118                                                  InputPixelType,
00119                                                  OutputPixelType > ) );
00120 
00121   itkConceptMacro( InputHasNumericTraitsCheck,
00122                    ( Concept::HasNumericTraits< InputPixelType > ) );
00124 #endif
00125 protected:
00126   MeanProjectionImageFilter() {}
00127   virtual ~MeanProjectionImageFilter() {}
00128 private:
00129   MeanProjectionImageFilter(const Self &); //purposely not implemented
00130   void operator=(const Self &);            //purposely not implemented
00131 };                                         // end MeanProjectionImageFilter
00132 } //end namespace itk
00134 
00135 #endif
00136