Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkMedianProjectionImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkMedianProjectionImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008/02/08 04:52:21 $
00007   Version:   $Revision: 1.1 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 
00018 #ifndef __itkMedianProjectionImageFilter_h
00019 #define __itkMedianProjectionImageFilter_h
00020 
00021 #include "itkProjectionImageFilter.h"
00022 #include "itkNumericTraits.h"
00023 #include "itkConceptChecking.h"
00024 
00025 #include <vector>
00026 #include <algorithm>
00027 
00028 namespace itk {
00050 namespace Function {
00051 template <class TInputPixel>
00052 class MedianAccumulator
00053 {
00054 public:
00055   MedianAccumulator( unsigned long size )
00056     {
00057     m_Values.reserve( size );
00058     }
00059   ~MedianAccumulator(){}
00060 
00061   inline void Initialize()
00062     {
00063     m_Values.clear();
00064     }
00065 
00066   inline void operator()( const TInputPixel &input )
00067     {
00068     m_Values.push_back( input );
00069     }
00070 
00071   inline TInputPixel GetValue()
00072     {
00073     typedef typename std::vector<TInputPixel>::iterator ContainerIterator;
00074     ContainerIterator medianIterator = m_Values.begin() +  m_Values.size() / 2;
00075     std::nth_element(m_Values.begin(), medianIterator, m_Values.end() );
00076     return *medianIterator;
00077     }
00078 
00079   std::vector<TInputPixel> m_Values;
00080 };
00081 } // end namespace Function
00082 
00083 
00084 template <class TInputImage, class TOutputImage>
00085 class ITK_EXPORT MedianProjectionImageFilter : public
00086   ProjectionImageFilter<TInputImage, TOutputImage, 
00087     Function::MedianAccumulator< typename TInputImage::PixelType > >
00088 {
00089 public:
00090   typedef MedianProjectionImageFilter Self;
00091   typedef ProjectionImageFilter<TInputImage, TOutputImage, 
00092     Function::MedianAccumulator< 
00093       typename TInputImage::PixelType > > Superclass;
00094 
00095   typedef SmartPointer<Self>        Pointer;
00096   typedef SmartPointer<const Self>  ConstPointer;
00097 
00099   itkTypeMacro(MedianProjectionImageFilter, ProjectionImageFilter);
00100 
00102   itkNewMacro(Self);
00103 
00104 #ifdef ITK_USE_CONCEPT_CHECKING
00105 
00108 #endif
00109 
00110 protected:
00111   MedianProjectionImageFilter() {}
00112   virtual ~MedianProjectionImageFilter() {}
00113 
00114 private:
00115   MedianProjectionImageFilter(const Self&); //purposely not implemented
00116   void operator=(const Self&); //purposely not implemented
00117 
00118 
00119 }; // end MedianProjectionImageFilter
00120 
00121 } //end namespace itk
00122 
00123 #endif
00124 

Generated at Wed Nov 5 22:50:32 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000