ITK  4.13.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 BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage,
45  Functor::DivideOrZeroOut<
46  typename TInputImage1::PixelType,
47  typename TInputImage2::PixelType,
48  typename TOutputImage::PixelType > >
49 {
50 public:
53  typedef BinaryFunctorImageFilter<TInputImage1, TInputImage2, TOutputImage,
55  typename TInputImage1::PixelType,
56  typename TInputImage2::PixelType,
57  typename TOutputImage::PixelType > > Superclass;
60 
61  typedef typename TInputImage1::PixelType NumeratorPixelType;
62  typedef typename TInputImage2::PixelType DenominatorPixelType;
63  typedef typename TOutputImage::PixelType OutputPixelType;
64 
66  itkNewMacro(Self);
67 
70 
72  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE
73  {
74  Superclass::PrintSelf(os, indent);
75  os << indent << "Threshold: " << GetThreshold() << std::endl;
76  }
78 
82  {
83  if ( Math::NotExactlyEquals(threshold, this->GetFunctor().m_Threshold) )
84  {
85  this->GetFunctor().m_Threshold = threshold;
86  this->Modified();
87  }
88  }
90  {
91  return this->GetFunctor().m_Threshold;
92  }
94 
97  void SetConstant( OutputPixelType constant )
98  {
99  if ( Math::NotExactlyEquals(constant, this->GetFunctor().m_Constant) )
100  {
101  this->GetFunctor().m_Constant = constant;
102  this->Modified();
103  }
104  }
106  {
107  return this->GetFunctor().m_Constant;
108  }
110 
111 protected:
113  virtual ~DivideOrZeroOutImageFilter() ITK_OVERRIDE {};
114 
115 private:
116  ITK_DISALLOW_COPY_AND_ASSIGN(DivideOrZeroOutImageFilter);
117 };
118 
119 } // end namespace itk
120 #endif
void SetConstant(OutputPixelType constant)
void SetThreshold(DenominatorPixelType threshold)
Base class for all process objects that output image data.
virtual void PrintSelf(std::ostream &os, Indent indent) const override
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:721
virtual void Modified() const
BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage, Functor::DivideOrZeroOut< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > > Superclass
Control indentation during Print() invocation.
Definition: itkIndent.h:49
DenominatorPixelType GetThreshold() const
void PrintSelf(std::ostream &os, Indent indent) const override
Implements pixel-wise generic operation of two images, or of an image and a constant.