Orfeo Toolbox
3.16
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
OTB
Utilities
ITK
Code
Numerics
Statistics
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
20
#include "
itkHistogramToImageFilter.h
"
21
22
namespace
itk
23
{
24
46
namespace
Function {
47
template
<
class
TInput,
class
TOutput=
double
>
48
class
HistogramLogProbabilityFunction
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
59
HistogramLogProbabilityFunction
():
60
m_TotalFrequency
(1) {}
61
62
~HistogramLogProbabilityFunction
() {};
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
>
94
class
ITK_EXPORT
HistogramToLogProbabilityImageFilter
:
95
public
HistogramToImageFilter
< THistogram,
96
Function::HistogramLogProbabilityFunction< unsigned long, TOutputPixel > >
97
{
98
public
:
99
101
typedef
HistogramToLogProbabilityImageFilter
Self
;
102
104
typedef
HistogramToImageFilter
< THistogram,
105
Function::HistogramLogProbabilityFunction< unsigned long, TOutputPixel >
>
106
Superclass
;
107
108
typedef
SmartPointer<Self>
Pointer
;
109
typedef
SmartPointer<const Self>
ConstPointer
;
110
112
itkTypeMacro(
HistogramToLogProbabilityImageFilter
,
HistogramToImageFilter
);
113
115
itkNewMacro(
Self
);
116
117
protected
:
118
HistogramToLogProbabilityImageFilter
() {}
119
virtual
~HistogramToLogProbabilityImageFilter
() {}
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