ITK  6.0.0
Insight Toolkit
itkDivideOrZeroOutImageFilter.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 itkDivideOrZeroOutImageFilter_h
19#define itkDivideOrZeroOutImageFilter_h
20
22#include "itkNumericTraits.h"
23#include "itkMath.h"
25
26namespace itk
27{
28
29
39template <typename TInputImage1, typename TInputImage2 = TInputImage1, typename TOutputImage = TInputImage1>
40class ITK_TEMPLATE_EXPORT DivideOrZeroOutImageFilter
41 : public BinaryGeneratorImageFilter<TInputImage1, TInputImage2, TOutputImage>
42{
43public:
44 ITK_DISALLOW_COPY_AND_MOVE(DivideOrZeroOutImageFilter);
45
51
52 using FunctorType = Functor::DivideOrZeroOut<typename TInputImage1::PixelType,
53 typename TInputImage2::PixelType,
54 typename TOutputImage::PixelType>;
55
56 using NumeratorPixelType = typename TInputImage1::PixelType;
57 using DenominatorPixelType = typename TInputImage2::PixelType;
58 using OutputPixelType = typename TOutputImage::PixelType;
59
61 itkNewMacro(Self);
62
64 itkOverrideGetNameOfClassMacro(DivideOrZeroOutImageFilter);
65
67 void
68 PrintSelf(std::ostream & os, Indent indent) const override
69 {
70 Superclass::PrintSelf(os, indent);
71 os << indent << "Threshold: " << GetThreshold() << std::endl;
72 }
77 void
79 {
80 if (Math::NotExactlyEquals(threshold, this->GetFunctor().m_Threshold))
81 {
82 this->GetFunctor().m_Threshold = threshold;
83 this->Modified();
84 }
85 }
86 DenominatorPixelType
88 {
89 return this->GetFunctor().m_Threshold;
90 }
95 void
97 {
98 if (Math::NotExactlyEquals(constant, this->GetFunctor().m_Constant))
99 {
100 this->GetFunctor().m_Constant = constant;
101 this->Modified();
102 }
103 }
104 OutputPixelType
106 {
107 return this->GetFunctor().m_Constant;
108 }
111protected:
113 ~DivideOrZeroOutImageFilter() override = default;
114
115 void
117 {
118 this->SetFunctor(this->GetFunctor());
119 }
120
121private:
122 itkGetConstReferenceMacro(Functor, FunctorType);
125 {
126 return m_Functor;
127 }
128
129 FunctorType m_Functor{};
130};
131
132} // end namespace itk
133#endif
Implements pixel-wise generic operation of two images, or of an image and a constant.
DenominatorPixelType GetThreshold() const
typename TInputImage1::PixelType NumeratorPixelType
void SetThreshold(DenominatorPixelType threshold)
typename TInputImage2::PixelType DenominatorPixelType
void PrintSelf(std::ostream &os, Indent indent) const override
typename TOutputImage::PixelType OutputPixelType
~DivideOrZeroOutImageFilter() override=default
void SetConstant(OutputPixelType constant)
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:737
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....