ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkDivideOrZeroOutImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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,
41  typename TInputImage2=TInputImage1,
42  typename TOutputImage=TInputImage1 >
44  public BinaryGeneratorImageFilter< TInputImage1, TInputImage2, TOutputImage >
45 {
46 public:
47  ITK_DISALLOW_COPY_AND_ASSIGN(DivideOrZeroOutImageFilter);
48 
54 
55  using FunctorType = Functor::DivideOrZeroOut< typename TInputImage1::PixelType,
56  typename TInputImage2::PixelType,
57  typename TOutputImage::PixelType >;
58 
59  using NumeratorPixelType = typename TInputImage1::PixelType;
60  using DenominatorPixelType = typename TInputImage2::PixelType;
61  using OutputPixelType = typename TOutputImage::PixelType;
62 
64  itkNewMacro(Self);
65 
68 
70  void PrintSelf(std::ostream& os, Indent indent) const override
71  {
72  Superclass::PrintSelf(os, indent);
73  os << indent << "Threshold: " << GetThreshold() << std::endl;
74  }
76 
80  {
81  if ( Math::NotExactlyEquals(threshold, this->GetFunctor().m_Threshold) )
82  {
83  this->GetFunctor().m_Threshold = threshold;
84  this->Modified();
85  }
86  }
88  {
89  return this->GetFunctor().m_Threshold;
90  }
92 
95  void SetConstant( OutputPixelType constant )
96  {
97  if ( Math::NotExactlyEquals(constant, this->GetFunctor().m_Constant) )
98  {
99  this->GetFunctor().m_Constant = constant;
100  this->Modified();
101  }
102  }
104  {
105  return this->GetFunctor().m_Constant;
106  }
108 
109 protected:
110  DivideOrZeroOutImageFilter() = default;
111  ~DivideOrZeroOutImageFilter() override = default;
112 
114  {
115  this->SetFunctor(this->GetFunctor());
116  }
117 
118 private:
119  itkGetConstReferenceMacro(Functor, FunctorType);
121 
123 };
124 
125 } // end namespace itk
126 #endif
void PrintSelf(std::ostream &os, Indent indent) const override
void SetConstant(OutputPixelType constant)
void SetThreshold(DenominatorPixelType threshold)
typename TOutputImage::PixelType OutputPixelType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
virtual const FunctorType & GetFunctor() const
Implements pixel-wise generic operation of two images, or of an image and a constant.
typename TInputImage1::PixelType NumeratorPixelType
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:718
virtual void Modified() const
void SetFunctor(const std::function< ConstRefFunctionType > &f)
Functor::DivideOrZeroOut< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > FunctorType
~DivideOrZeroOutImageFilter() override=default
Control indentation during Print() invocation.
Definition: itkIndent.h:49
DenominatorPixelType GetThreshold() const
void PrintSelf(std::ostream &os, Indent indent) const override
typename TInputImage2::PixelType DenominatorPixelType