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 
26 namespace itk
27 {
28 
29 
40 template <typename TInputImage1, typename TInputImage2 = TInputImage1, typename TOutputImage = TInputImage1>
41 class ITK_TEMPLATE_EXPORT DivideOrZeroOutImageFilter
42  : public BinaryGeneratorImageFilter<TInputImage1, TInputImage2, TOutputImage>
43 {
44 public:
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
88  GetThreshold() const
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
106  GetConstant() const
107  {
108  return this->GetFunctor().m_Constant;
109  }
112 protected:
113  DivideOrZeroOutImageFilter() = default;
114  ~DivideOrZeroOutImageFilter() override = default;
115 
116  void
118  {
119  this->SetFunctor(this->GetFunctor());
120  }
121 
122 private:
123  itkGetConstReferenceMacro(Functor, FunctorType);
124  FunctorType &
126  {
127  return m_Functor;
128  }
129 
130  FunctorType m_Functor{};
131 };
132 
133 } // end namespace itk
134 #endif
itk::DivideOrZeroOutImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkDivideOrZeroOutImageFilter.h:69
itk::DivideOrZeroOutImageFilter::DenominatorPixelType
typename TInputImage2::PixelType DenominatorPixelType
Definition: itkDivideOrZeroOutImageFilter.h:58
itk::DivideOrZeroOutImageFilter::GetFunctor
FunctorType & GetFunctor()
Definition: itkDivideOrZeroOutImageFilter.h:125
itk::BinaryGeneratorImageFilter
Implements pixel-wise generic operation of two images, or of an image and a constant.
Definition: itkBinaryGeneratorImageFilter.h:56
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::Math::NotExactlyEquals
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:736
itk::DivideOrZeroOutImageFilter::GetThreshold
DenominatorPixelType GetThreshold() const
Definition: itkDivideOrZeroOutImageFilter.h:88
itk::DivideOrZeroOutImageFilter
Definition: itkDivideOrZeroOutImageFilter.h:41
itk::DivideOrZeroOutImageFilter::SetThreshold
void SetThreshold(DenominatorPixelType threshold)
Definition: itkDivideOrZeroOutImageFilter.h:79
itkBinaryGeneratorImageFilter.h
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::DivideOrZeroOutImageFilter::GetConstant
OutputPixelType GetConstant() const
Definition: itkDivideOrZeroOutImageFilter.h:106
itk::Functor::DivideOrZeroOut< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType >
itkArithmeticOpsFunctors.h
FunctorType
Functor::Add2< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > FunctorType
Definition: itkAddImageFilter.h:97
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::DivideOrZeroOutImageFilter::NumeratorPixelType
typename TInputImage1::PixelType NumeratorPixelType
Definition: itkDivideOrZeroOutImageFilter.h:57
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::DivideOrZeroOutImageFilter::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkDivideOrZeroOutImageFilter.h:59
itkNumericTraits.h
itk::DivideOrZeroOutImageFilter::SetConstant
void SetConstant(OutputPixelType constant)
Definition: itkDivideOrZeroOutImageFilter.h:97
itk::DivideOrZeroOutImageFilter::BeforeThreadedGenerateData
void BeforeThreadedGenerateData() override
Definition: itkDivideOrZeroOutImageFilter.h:117
itkMath.h