Orfeo Toolbox  3.16
itkHistogramToLogProbabilityImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkHistogramToLogProbabilityImageFilter.h,v $
5  Language: C++
6  Date: $Date: 2009-04-06 11:51:06 $
7  Version: $Revision: 1.11 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkHistogramToLogProbabilityImageFilter_h
18 #define __itkHistogramToLogProbabilityImageFilter_h
19 
21 
22 namespace itk
23 {
24 
46 namespace Function {
47 template< class TInput, class TOutput=double >
49 {
50 public:
51 
52  //Probability function = Number of occurances in each bin /
53  // Total Number of occurances.
54  //
55  // Returns pixels of float..
56  typedef TOutput OutputPixelType;
57 
58 
60  m_TotalFrequency(1) {}
61 
63 
64  inline OutputPixelType operator()( const TInput & A ) const
65  {
66  if( A )
67  {
68  return static_cast<OutputPixelType>(vcl_log( static_cast<OutputPixelType>(A) /
69  static_cast<OutputPixelType>(m_TotalFrequency)) / vcl_log(2.0) );
70  }
71  else
72  { // Check for Log 0. Always assume that the frequency is atleast 1.
73  return static_cast<OutputPixelType>(vcl_log( static_cast<OutputPixelType>(A+1) /
74  static_cast<OutputPixelType>(m_TotalFrequency)) / vcl_log(2.0) );
75  }
76  }
77 
78  void SetTotalFrequency( unsigned long n )
79  {
80  m_TotalFrequency = n;
81  }
82 
83  unsigned long GetTotalFrequency( ) const
84  {
85  return m_TotalFrequency;
86  }
87 
88 private:
89  unsigned long m_TotalFrequency;
90 };
91 }
92 
93 template <class THistogram, class TOutputPixel=double >
95  public HistogramToImageFilter< THistogram,
96  Function::HistogramLogProbabilityFunction< unsigned long, TOutputPixel > >
97 {
98 public:
99 
102 
104  typedef HistogramToImageFilter< THistogram,
107 
110 
113 
115  itkNewMacro(Self);
116 
117 protected:
120 
121 private:
122  HistogramToLogProbabilityImageFilter(const Self&); //purposely not implemented
123  void operator=(const Self&); //purposely not implemented
124 
125 };
126 
127 } // end namespace itk
128 
129 #endif

Generated at Sat Feb 2 2013 23:41:47 for Orfeo Toolbox with doxygen 1.8.1.1