ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkHistogramToLogProbabilityImageFilter.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 itkHistogramToLogProbabilityImageFilter_h
19#define itkHistogramToLogProbabilityImageFilter_h
20
22
23namespace itk
24{
46
47namespace Function
48{
49template <typename TInput, typename TOutput = double>
51{
52public:
53 // Probability function = Number of occurrences in each bin /
54 // Total Number of occurrences.
55 //
56 // Returns pixels of float..
57 using OutputPixelType = TOutput;
58
60
62
63 inline OutputPixelType
64 operator()(const TInput & A) const
65 {
66 if (A)
67 {
68 return static_cast<OutputPixelType>(
69 std::log(static_cast<OutputPixelType>(A) / static_cast<OutputPixelType>(m_TotalFrequency)) / std::log(2.0));
70 }
71
72 // Check for Log 0. Always assume that the frequency is at least 1.
73 return static_cast<OutputPixelType>(
74 std::log(static_cast<OutputPixelType>(A + 1) / static_cast<OutputPixelType>(m_TotalFrequency)) / std::log(2.0));
75 }
76
77 void
82
85 {
86 return m_TotalFrequency;
87 }
88
89private:
91};
92} // namespace Function
93
94template <typename THistogram, typename TImage = Image<double, 3>>
96 : public HistogramToImageFilter<THistogram,
97 TImage,
98 Function::HistogramLogProbabilityFunction<SizeValueType, typename TImage::PixelType>>
99{
100public:
101 ITK_DISALLOW_COPY_AND_MOVE(HistogramToLogProbabilityImageFilter);
102
105
108 HistogramToImageFilter<THistogram,
109 TImage,
111
114
116 itkOverrideGetNameOfClassMacro(HistogramToLogProbabilityImageFilter);
117
119 itkNewMacro(Self);
120
121protected:
124};
125} // end namespace itk
126
127#endif
~HistogramToLogProbabilityImageFilter() override=default
HistogramToImageFilter< THistogram, TImage, Function::HistogramLogProbabilityFunction< SizeValueType, typename TImage::PixelType > > Superclass
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition itkIntTypes.h:86