Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkHistogramToLogProbabilityImageFilter_h
00018 #define __itkHistogramToLogProbabilityImageFilter_h
00019
00020 #include "itkHistogramToImageFilter.h"
00021
00022 namespace itk
00023 {
00024
00046 namespace Function {
00047 template< class TInput, class TOutput=double >
00048 class HistogramLogProbabilityFunction
00049 {
00050 public:
00051
00052
00053
00054
00055
00056 typedef TOutput OutputPixelType;
00057
00058
00059 HistogramLogProbabilityFunction():
00060 m_TotalFrequency(1) {}
00061
00062 ~HistogramLogProbabilityFunction() {};
00063
00064 inline OutputPixelType operator()( const TInput & A ) const
00065 {
00066 if( A )
00067 {
00068 return static_cast<OutputPixelType>(vcl_log( static_cast<OutputPixelType>(A) /
00069 static_cast<OutputPixelType>(m_TotalFrequency)) / vcl_log(2.0) );
00070 }
00071 else
00072 {
00073 return static_cast<OutputPixelType>(vcl_log( static_cast<OutputPixelType>(A+1) /
00074 static_cast<OutputPixelType>(m_TotalFrequency)) / vcl_log(2.0) );
00075 }
00076 }
00077
00078 void SetTotalFrequency( unsigned long n )
00079 {
00080 m_TotalFrequency = n;
00081 }
00082
00083 unsigned long GetTotalFrequency( ) const
00084 {
00085 return m_TotalFrequency;
00086 }
00087
00088 private:
00089 unsigned long m_TotalFrequency;
00090 };
00091 }
00092
00093 template <class THistogram, unsigned int NDimension, class TOutputPixel=double >
00094 class ITK_EXPORT HistogramToLogProbabilityImageFilter :
00095 public HistogramToImageFilter< THistogram, NDimension,
00096 Function::HistogramLogProbabilityFunction< unsigned long, TOutputPixel > >
00097 {
00098 public:
00099
00101 typedef HistogramToLogProbabilityImageFilter Self;
00102
00104 typedef HistogramToImageFilter< THistogram, NDimension,
00105 Function::HistogramLogProbabilityFunction< unsigned long, TOutputPixel > >
00106 Superclass;
00107
00108 typedef SmartPointer<Self> Pointer;
00109 typedef SmartPointer<const Self> ConstPointer;
00110
00112 itkTypeMacro( HistogramToLogProbabilityImageFilter, HistogramToImageFilter );
00113
00115 itkNewMacro(Self);
00116
00117 protected:
00118 HistogramToLogProbabilityImageFilter() {}
00119 virtual ~HistogramToLogProbabilityImageFilter() {}
00120
00121 private:
00122 HistogramToLogProbabilityImageFilter(const Self&);
00123 void operator=(const Self&);
00124
00125 };
00126
00127 }
00128
00129 #endif
00130