ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkSumProjectionImageFilter.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 __itkSumProjectionImageFilter_h
00019 #define __itkSumProjectionImageFilter_h
00020 
00021 #include "itkProjectionImageFilter.h"
00022 #include "itkConceptChecking.h"
00023 
00024 namespace itk
00025 {
00047 namespace Functor
00048 {
00049 template< class TInputPixel, class TOuputPixel >
00050 class SumAccumulator
00051 {
00052 public:
00053   SumAccumulator( SizeValueType ) {}
00054   ~SumAccumulator(){}
00055 
00056   inline void Initialize()
00057   {
00058     m_Sum = NumericTraits< TOuputPixel >::Zero;
00059   }
00060 
00061   inline TInputPixel operator()(const TInputPixel & input)
00062   {
00063     m_Sum = m_Sum + input;
00064     return m_Sum;
00065   }
00066 
00067   inline TOuputPixel GetValue()
00068   {
00069     return m_Sum;
00070   }
00071 
00072   TOuputPixel m_Sum;
00073 };
00074 } // end namespace Function
00075 
00076 template< class TInputImage, class TOutputImage >
00077 class ITK_EXPORT SumProjectionImageFilter:
00078   public
00079   ProjectionImageFilter< TInputImage, TOutputImage,
00080                          Functor::SumAccumulator<
00081                            typename TInputImage::PixelType, typename TOutputImage::PixelType > >
00082 {
00083 public:
00084   typedef SumProjectionImageFilter Self;
00085   typedef ProjectionImageFilter< TInputImage, TOutputImage,
00086                                  Functor::SumAccumulator<
00087                                    typename TInputImage::PixelType,
00088                                    typename TOutputImage::PixelType > > Superclass;
00089 
00090   typedef TInputImage                        InputImageType;
00091   typedef typename InputImageType::PixelType InputPixelType;
00092 
00093   typedef TOutputImage                        OutputImageType;
00094   typedef typename OutputImageType::PixelType OutputPixelType;
00095 
00096   typedef SmartPointer< Self >       Pointer;
00097   typedef SmartPointer< const Self > ConstPointer;
00098 
00100   itkTypeMacro(SumProjectionImageFilter, ProjectionImageFilter);
00101 
00103   itkNewMacro(Self);
00104 
00105 #ifdef ITK_USE_CONCEPT_CHECKING
00106 
00107   itkConceptMacro( InputPixelToOutputPixelTypeGreaterAdditiveOperatorCheck,
00108                    ( Concept::AdditiveOperators< OutputPixelType,
00109                                                  InputPixelType,
00110                                                  OutputPixelType > ) );
00111   itkConceptMacro( InputHasNumericTraitsCheck,
00112                    ( Concept::HasNumericTraits< InputPixelType > ) );
00113 
00115 #endif
00116 protected:
00117   SumProjectionImageFilter() {}
00118   virtual ~SumProjectionImageFilter() {}
00119 private:
00120   SumProjectionImageFilter(const Self &); //purposely not implemented
00121   void operator=(const Self &);           //purposely not implemented
00122 };                                        // end SumProjectionImageFilter
00123 } //end namespace itk
00125 
00126 #endif
00127