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

itkHistogramToProbabilityImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkHistogramToProbabilityImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-04-01 14:36:37 $
00007   Version:   $Revision: 1.8 $
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 #ifndef __itkHistogramToProbabilityImageFilter_h
00018 #define __itkHistogramToProbabilityImageFilter_h
00019 
00020 #include "itkHistogramToImageFilter.h"
00021 
00022 namespace itk
00023 {
00024   
00046 namespace Function {  
00047 template< class TInput, class TOutput=float >
00048 class HistogramProbabilityFunction
00049 {
00050 public:
00051   
00052   //Probability function = Number of occurances in each bin /
00053   //   Total Number of occurances. 
00054   //
00055   // Returns pixels of float.. 
00056   typedef  TOutput  OutputPixelType;
00057   
00058   
00059   HistogramProbabilityFunction(): 
00060       m_TotalFrequency(1) {}
00061 
00062   ~HistogramProbabilityFunction() {};
00063 
00064   inline OutputPixelType operator()( const TInput & A ) const
00065     {
00066     return static_cast<OutputPixelType>( static_cast<OutputPixelType>(A) / 
00067         static_cast<OutputPixelType>(m_TotalFrequency) );
00068     }
00069 
00070   void SetTotalFrequency( unsigned long n ) 
00071     {
00072     m_TotalFrequency = n;
00073     }
00074   
00075   unsigned long GetTotalFrequency( ) const 
00076     {
00077     return m_TotalFrequency;
00078     }
00079 
00080 private:
00081   unsigned long  m_TotalFrequency;
00082 }; 
00083 }
00084 
00085 template <class THistogram, class TOutputPixel=float >
00086 class ITK_EXPORT HistogramToProbabilityImageFilter :
00087   public HistogramToImageFilter< THistogram, 
00088   Function::HistogramProbabilityFunction< unsigned long, TOutputPixel > > 
00089 {
00090 public:
00091   
00093   typedef HistogramToProbabilityImageFilter Self;
00094 
00096   typedef HistogramToImageFilter< THistogram, 
00097     Function::HistogramProbabilityFunction< unsigned long, TOutputPixel> >
00098                                             Superclass;
00099 
00100   typedef SmartPointer<Self>                Pointer;
00101   typedef SmartPointer<const Self>          ConstPointer;
00102   
00104   itkTypeMacro( HistogramToProbabilityImageFilter, HistogramToImageFilter );
00105 
00107   itkNewMacro(Self);
00108 
00109 protected:
00110   HistogramToProbabilityImageFilter() {}
00111   virtual ~HistogramToProbabilityImageFilter() {}
00112   
00113 private:
00114   HistogramToProbabilityImageFilter(const Self&); //purposely not implemented
00115   void operator=(const Self&); //purposely not implemented
00116 
00117 };
00118 
00119 } // end namespace itk
00120 
00121 #endif
00122 

Generated at Tue Sep 15 03:13:26 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000