ITK  5.2.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  * http://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 DivideOrZeroOutImageFilter : public BinaryGeneratorImageFilter<TInputImage1, TInputImage2, TOutputImage>
42 {
43 public:
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 
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  }
74 
77  void
79  {
80  if (Math::NotExactlyEquals(threshold, this->GetFunctor().m_Threshold))
81  {
82  this->GetFunctor().m_Threshold = threshold;
83  this->Modified();
84  }
85  }
87  GetThreshold() const
88  {
89  return this->GetFunctor().m_Threshold;
90  }
92 
95  void
97  {
98  if (Math::NotExactlyEquals(constant, this->GetFunctor().m_Constant))
99  {
100  this->GetFunctor().m_Constant = constant;
101  this->Modified();
102  }
103  }
105  GetConstant() const
106  {
107  return this->GetFunctor().m_Constant;
108  }
110 
111 protected:
112  DivideOrZeroOutImageFilter() = default;
113  ~DivideOrZeroOutImageFilter() override = default;
114 
115  void
117  {
118  this->SetFunctor(this->GetFunctor());
119  }
120 
121 private:
122  itkGetConstReferenceMacro(Functor, FunctorType);
123  FunctorType &
125  {
126  return m_Functor;
127  }
128 
130 };
131 
132 } // end namespace itk
133 #endif
itk::DivideOrZeroOutImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkDivideOrZeroOutImageFilter.h:68
itk::DivideOrZeroOutImageFilter::DenominatorPixelType
typename TInputImage2::PixelType DenominatorPixelType
Definition: itkDivideOrZeroOutImageFilter.h:57
itk::DivideOrZeroOutImageFilter::GetFunctor
FunctorType & GetFunctor()
Definition: itkDivideOrZeroOutImageFilter.h:124
itk::DivideOrZeroOutImageFilter::DivideOrZeroOutImageFilter
DivideOrZeroOutImageFilter()=default
itk::DivideOrZeroOutImageFilter::GetFunctor
virtual const FunctorType & GetFunctor() const
itk::DivideOrZeroOutImageFilter::~DivideOrZeroOutImageFilter
~DivideOrZeroOutImageFilter() override=default
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:733
itk::DivideOrZeroOutImageFilter::GetThreshold
DenominatorPixelType GetThreshold() const
Definition: itkDivideOrZeroOutImageFilter.h:87
itk::DivideOrZeroOutImageFilter
Definition: itkDivideOrZeroOutImageFilter.h:41
itk::DivideOrZeroOutImageFilter::SetThreshold
void SetThreshold(DenominatorPixelType threshold)
Definition: itkDivideOrZeroOutImageFilter.h:78
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:105
itk::Functor::DivideOrZeroOut< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType >
itkArithmeticOpsFunctors.h
itk::InPlaceImageFilter< TInputImage1, TOutputImage >::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::Functor::DivideOrZeroOut::m_Constant
TOutput m_Constant
Definition: itkArithmeticOpsFunctors.h:237
itk::Functor::DivideOrZeroOut::m_Threshold
TDenominator m_Threshold
Definition: itkArithmeticOpsFunctors.h:236
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:56
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::DivideOrZeroOutImageFilter::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkDivideOrZeroOutImageFilter.h:58
itkNumericTraits.h
itk::DivideOrZeroOutImageFilter::SetConstant
void SetConstant(OutputPixelType constant)
Definition: itkDivideOrZeroOutImageFilter.h:96
itk::DivideOrZeroOutImageFilter::BeforeThreadedGenerateData
void BeforeThreadedGenerateData() override
Definition: itkDivideOrZeroOutImageFilter.h:116
itk::Object::Modified
virtual void Modified() const
itkMath.h
itk::DivideOrZeroOutImageFilter::m_Functor
FunctorType m_Functor
Definition: itkDivideOrZeroOutImageFilter.h:129
itk::BinaryGeneratorImageFilter::SetFunctor
void SetFunctor(const std::function< ConstRefFunctionType > &f)
Definition: itkBinaryGeneratorImageFilter.h:150
itk::DivideOrZeroOutImageFilter::FunctorType
Functor::DivideOrZeroOut< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > FunctorType
Definition: itkDivideOrZeroOutImageFilter.h:54