ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkHistogramToEntropyImageFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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
22
23namespace itk
24{
52
53namespace Function
54{
55template <typename TInput, typename TOutput = double>
57{
58public:
59 // Probability function = Number of occurrences in each bin /
60 // Total Number of occurrences.
61 //
62 // Returns pixels of float..
63 using OutputPixelType = TOutput;
64
66
68
69 inline OutputPixelType
70 operator()(const TInput & A) const
71 {
72 if (A)
73 {
74 const double p = static_cast<OutputPixelType>(A) / static_cast<OutputPixelType>(m_TotalFrequency);
75 return static_cast<OutputPixelType>((-1) * p * std::log(p) / std::log(2.0));
76 }
77
78 const double p = static_cast<OutputPixelType>(A + 1) / static_cast<OutputPixelType>(m_TotalFrequency);
79 return static_cast<OutputPixelType>((-1) * p * std::log(p) / std::log(2.0));
80 }
81
82 void
87
90 {
91 return m_TotalFrequency;
92 }
93
94private:
96};
97} // namespace Function
98
99template <typename THistogram, typename TImage = Image<double, 3>>
101 : public HistogramToImageFilter<THistogram,
102 TImage,
103 Function::HistogramEntropyFunction<SizeValueType, typename TImage::PixelType>>
104{
105public:
106 ITK_DISALLOW_COPY_AND_MOVE(HistogramToEntropyImageFilter);
107
110
113 HistogramToImageFilter<THistogram,
114 TImage,
116
119
121 itkOverrideGetNameOfClassMacro(HistogramToEntropyImageFilter);
122
124 itkNewMacro(Self);
125
126protected:
128 ~HistogramToEntropyImageFilter() override = default;
129};
130} // end namespace itk
131
132#endif
OutputPixelType operator()(const TInput &A) const
HistogramToImageFilter< THistogram, TImage, Function::HistogramEntropyFunction< SizeValueType, typename TImage::PixelType > > Superclass
~HistogramToEntropyImageFilter() override=default
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition itkIntTypes.h:86