ITK  6.0.0
Insight Toolkit
itkHistogramToProbabilityImageFilter.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 itkHistogramToProbabilityImageFilter_h
19 #define itkHistogramToProbabilityImageFilter_h
20 
22 
23 namespace itk
24 {
48 namespace Function
49 {
50 template <typename TInput, typename TOutput = float>
52 {
53 public:
54  // Probability function = Number of occurrences in each bin /
55  // Total Number of occurrences.
56  //
57  // Returns pixels of float..
58  using OutputPixelType = TOutput;
59 
60  HistogramProbabilityFunction() = default;
61 
63 
64  inline OutputPixelType
65  operator()(const TInput & A) const
66  {
67  return static_cast<OutputPixelType>(static_cast<OutputPixelType>(A) /
68  static_cast<OutputPixelType>(m_TotalFrequency));
69  }
70 
71  void
73  {
74  m_TotalFrequency = n;
75  }
76 
79  {
80  return m_TotalFrequency;
81  }
82 
83 private:
85 };
86 } // namespace Function
87 
88 template <typename THistogram, typename TImage = Image<float, 3>>
90  : public HistogramToImageFilter<THistogram,
91  TImage,
92  Function::HistogramProbabilityFunction<SizeValueType, typename TImage::PixelType>>
93 {
94 public:
95  ITK_DISALLOW_COPY_AND_MOVE(HistogramToProbabilityImageFilter);
96 
99 
101  using Superclass =
102  HistogramToImageFilter<THistogram,
103  TImage,
105 
108 
110  itkOverrideGetNameOfClassMacro(HistogramToProbabilityImageFilter);
111 
113  itkNewMacro(Self);
114 
115 protected:
117  ~HistogramToProbabilityImageFilter() override = default;
118 };
119 } // end namespace itk
120 
121 #endif
itk::Function::HistogramProbabilityFunction::m_TotalFrequency
SizeValueType m_TotalFrequency
Definition: itkHistogramToProbabilityImageFilter.h:84
itk::Function::HistogramProbabilityFunction::HistogramProbabilityFunction
HistogramProbabilityFunction()=default
itk::HistogramToProbabilityImageFilter::~HistogramToProbabilityImageFilter
~HistogramToProbabilityImageFilter() override=default
itk::Function::HistogramProbabilityFunction::SetTotalFrequency
void SetTotalFrequency(SizeValueType n)
Definition: itkHistogramToProbabilityImageFilter.h:72
itk::Function::HistogramProbabilityFunction::~HistogramProbabilityFunction
~HistogramProbabilityFunction()=default
itkHistogramToImageFilter.h
itk::SmartPointer< Self >
itk::Function::HistogramProbabilityFunction
Definition: itkHistogramToProbabilityImageFilter.h:51
itk::Function::HistogramProbabilityFunction::operator()
OutputPixelType operator()(const TInput &A) const
Definition: itkHistogramToProbabilityImageFilter.h:65
itk::Function::HistogramProbabilityFunction< SizeValueType, TImage::PixelType >::OutputPixelType
TImage::PixelType OutputPixelType
Definition: itkHistogramToProbabilityImageFilter.h:58
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::HistogramToProbabilityImageFilter::HistogramToProbabilityImageFilter
HistogramToProbabilityImageFilter()=default
itk::Function::HistogramProbabilityFunction::GetTotalFrequency
SizeValueType GetTotalFrequency() const
Definition: itkHistogramToProbabilityImageFilter.h:78
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::HistogramToImageFilter
This class takes a histogram as an input and returns an image of type specified by the functor.
Definition: itkHistogramToImageFilter.h:50
itk::HistogramToProbabilityImageFilter
The class takes a histogram as an input and gives the probability image as the output....
Definition: itkHistogramToProbabilityImageFilter.h:89
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86