ITK
4.3.0
Insight Segmentation and Registration Toolkit
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
ITK
Modules
Numerics
Statistics
include
itkHistogramToLogProbabilityImageFilter.h
Go to the documentation of this file.
1
/*=========================================================================
2
*
3
* Copyright Insight Software Consortium
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0.txt
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
*=========================================================================*/
18
#ifndef __itkHistogramToLogProbabilityImageFilter_h
19
#define __itkHistogramToLogProbabilityImageFilter_h
20
21
#include "
itkHistogramToImageFilter.h
"
22
23
namespace
itk
24
{
47
namespace
Function
48
{
49
template
<
class
TInput,
class
TOutput =
double
>
50
class
HistogramLogProbabilityFunction
51
{
52
public
:
53
54
//Probability function = Number of occurrences in each bin /
55
// Total Number of occurrences.
56
//
57
// Returns pixels of float..
58
typedef
TOutput
OutputPixelType
;
59
60
HistogramLogProbabilityFunction
():
61
m_TotalFrequency
(1) {}
62
63
~HistogramLogProbabilityFunction
() {}
64
65
inline
OutputPixelType
operator()
(
const
TInput & A)
const
66
{
67
if
( A )
68
{
69
return
static_cast<
OutputPixelType
>
( vcl_log( static_cast< OutputPixelType >( A )
70
/ static_cast< OutputPixelType >(
m_TotalFrequency
) )
71
/ vcl_log(2.0) );
72
}
73
else
74
{
// Check for Log 0. Always assume that the frequency is atleast 1.
75
return
static_cast<
OutputPixelType
>
( vcl_log( static_cast< OutputPixelType >( A + 1 )
76
/ static_cast< OutputPixelType >(
m_TotalFrequency
) )
77
/ vcl_log(2.0) );
78
}
79
}
80
81
void
SetTotalFrequency
(
SizeValueType
n)
82
{
83
m_TotalFrequency
= n;
84
}
85
86
SizeValueType
GetTotalFrequency
()
const
87
{
88
return
m_TotalFrequency
;
89
}
90
91
private
:
92
SizeValueType
m_TotalFrequency
;
93
};
94
}
95
96
template
<
class
THistogram,
class
TImage=Image<
double
, 3 > >
97
class
ITK_EXPORT
HistogramToLogProbabilityImageFilter
:
98
public
HistogramToImageFilter
< THistogram, TImage,
99
Function::HistogramLogProbabilityFunction< SizeValueType, typename TImage::PixelType > >
100
{
101
public
:
102
104
typedef
HistogramToLogProbabilityImageFilter
Self
;
105
107
typedef
HistogramToImageFilter
< THistogram, TImage,
108
Function::HistogramLogProbabilityFunction< SizeValueType, typename TImage::PixelType >
>
109
Superclass
;
110
111
typedef
SmartPointer< Self >
Pointer
;
112
typedef
SmartPointer< const Self >
ConstPointer
;
113
115
itkTypeMacro(
HistogramToLogProbabilityImageFilter
,
HistogramToImageFilter
);
116
118
itkNewMacro(
Self
);
119
120
protected
:
121
HistogramToLogProbabilityImageFilter
() {}
122
virtual
~HistogramToLogProbabilityImageFilter
() {}
123
124
private
:
125
HistogramToLogProbabilityImageFilter
(
const
Self &);
//purposely not
126
// implemented
127
void
operator=(
const
Self &);
//purposely not
128
// implemented
129
};
130
}
// end namespace itk
131
132
#endif
133
Generated on Sun Dec 9 2012 01:05:29 for ITK by
1.8.2