ITK
4.2.0
Insight Segmentation and Registration Toolkit
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
ITK
Modules
Numerics
Statistics
include
itkHistogramToEntropyImageFilter.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 __itkHistogramToEntropyImageFilter_h
19
#define __itkHistogramToEntropyImageFilter_h
20
21
#include "
itkHistogramToImageFilter.h
"
22
23
namespace
itk
24
{
52
namespace
Function
53
{
54
template
<
class
TInput,
class
TOutput =
double
>
55
class
HistogramEntropyFunction
56
{
57
public
:
58
59
//Probability function = Number of occurrences in each bin /
60
// Total Number of occurrences.
61
//
62
// Returns pixels of float..
63
typedef
TOutput
OutputPixelType
;
64
65
HistogramEntropyFunction
():
66
m_TotalFrequency
(1) {}
67
68
~HistogramEntropyFunction
() {}
69
70
inline
OutputPixelType
operator()
(
const
TInput & A)
const
71
{
72
if
( A )
73
{
74
const
double
p =
static_cast<
OutputPixelType
>
( A )
75
/ static_cast< OutputPixelType >(
m_TotalFrequency
);
76
return
static_cast<
OutputPixelType
>
( ( -1 ) * p * vcl_log(p) / vcl_log(2.0) );
77
}
78
else
79
{
80
const
double
p =
static_cast<
OutputPixelType
>
( A + 1 )
81
/ static_cast< OutputPixelType >(
m_TotalFrequency
);
82
return
static_cast<
OutputPixelType
>
( ( -1 ) * p * vcl_log(p) / vcl_log(2.0) );
83
}
84
}
85
86
void
SetTotalFrequency
(
const
SizeValueType
n)
87
{
88
m_TotalFrequency
= n;
89
}
90
91
SizeValueType
GetTotalFrequency
()
const
92
{
93
return
m_TotalFrequency
;
94
}
95
96
private
:
97
SizeValueType
m_TotalFrequency
;
98
};
99
}
100
101
template
<
class
THistogram,
class
TImage=Image<
double
, 3> >
102
class
ITK_EXPORT
HistogramToEntropyImageFilter
:
103
public
HistogramToImageFilter
< THistogram, TImage,
104
Function::HistogramEntropyFunction< SizeValueType, typename TImage::PixelType > >
105
{
106
public
:
107
109
typedef
HistogramToEntropyImageFilter
Self
;
110
112
typedef
HistogramToImageFilter
< THistogram, TImage,
113
Function::HistogramEntropyFunction< SizeValueType, typename TImage::PixelType >
>
114
Superclass
;
115
116
typedef
SmartPointer< Self >
Pointer
;
117
typedef
SmartPointer< const Self >
ConstPointer
;
118
120
itkTypeMacro(
HistogramToEntropyImageFilter
,
HistogramToImageFilter
);
121
123
itkNewMacro(
Self
);
124
protected
:
125
HistogramToEntropyImageFilter
() {}
126
virtual
~HistogramToEntropyImageFilter
() {}
127
private
:
128
HistogramToEntropyImageFilter
(
const
Self &);
//purposely not implemented
129
void
operator=(
const
Self &);
//purposely not implemented
130
};
131
}
// end namespace itk
133
134
#endif
135
Generated on Tue Jul 10 2012 23:28:28 for ITK by
1.8.1