ITK  5.4.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
40template <typename TInputImage1, typename TInputImage2 = TInputImage1, typename TOutputImage = TInputImage1>
41class ITK_TEMPLATE_EXPORT DivideOrZeroOutImageFilter
42 : public BinaryGeneratorImageFilter<TInputImage1, TInputImage2, TOutputImage>
43{
44public:
45 ITK_DISALLOW_COPY_AND_MOVE(DivideOrZeroOutImageFilter);
46
52
53 using FunctorType = Functor::DivideOrZeroOut<typename TInputImage1::PixelType,
54 typename TInputImage2::PixelType,
55 typename TOutputImage::PixelType>;
56
57 using NumeratorPixelType = typename TInputImage1::PixelType;
58 using DenominatorPixelType = typename TInputImage2::PixelType;
59 using OutputPixelType = typename TOutputImage::PixelType;
60
62 itkNewMacro(Self);
63
65 itkOverrideGetNameOfClassMacro(DivideOrZeroOutImageFilter);
66
68 void
69 PrintSelf(std::ostream & os, Indent indent) const override
70 {
71 Superclass::PrintSelf(os, indent);
72 os << indent << "Threshold: " << GetThreshold() << std::endl;
73 }
78 void
80 {
81 if (Math::NotExactlyEquals(threshold, this->GetFunctor().m_Threshold))
82 {
83 this->GetFunctor().m_Threshold = threshold;
84 this->Modified();
85 }
86 }
87 DenominatorPixelType
89 {
90 return this->GetFunctor().m_Threshold;
91 }
96 void
98 {
99 if (Math::NotExactlyEquals(constant, this->GetFunctor().m_Constant))
100 {
101 this->GetFunctor().m_Constant = constant;
102 this->Modified();
103 }
104 }
105 OutputPixelType
107 {
108 return this->GetFunctor().m_Constant;
109 }
112protected:
114 ~DivideOrZeroOutImageFilter() override = default;
115
116 void
118 {
119 this->SetFunctor(this->GetFunctor());
120 }
121
122private:
123 itkGetConstReferenceMacro(Functor, FunctorType);
126 {
127 return m_Functor;
128 }
129
130 FunctorType m_Functor{};
131};
132
133} // end namespace itk
134#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....