ITK  6.0.0
Insight Toolkit
itkDivideImageFilter.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 itkDivideImageFilter_h
19 #define itkDivideImageFilter_h
20 
23 #include "itkNumericTraits.h"
24 #include "itkMath.h"
25 
26 namespace itk
27 {
28 
47 template <typename TInputImage1, typename TInputImage2, typename TOutputImage>
48 class ITK_TEMPLATE_EXPORT DivideImageFilter
49  : public BinaryGeneratorImageFilter<TInputImage1, TInputImage2, TOutputImage>
50 {
51 public:
52  ITK_DISALLOW_COPY_AND_MOVE(DivideImageFilter);
53 
58 
63 
69  using FunctorType =
71 
75  itkNewMacro(Self);
76 
78  itkOverrideGetNameOfClassMacro(DivideImageFilter);
79 
80 #ifdef ITK_USE_CONCEPT_CHECKING
81  // Begin concept checking
83  itkConceptMacro(Input1Input2OutputDivisionOperatorsCheck,
84  (Concept::DivisionOperators<typename TInputImage1::PixelType,
85  typename TInputImage2::PixelType,
86  typename TOutputImage::PixelType>));
87  // End concept checking
88 #endif
89 
90 protected:
92  {
93 #if !defined(ITK_WRAPPING_PARSER)
94  Superclass::SetFunctor(FunctorType());
95 #endif
96  }
97 
98  ~DivideImageFilter() override = default;
99 
100  void
101  VerifyPreconditions() const override
102  {
103  Superclass::VerifyPreconditions();
104 
105  const auto * input =
106  dynamic_cast<const typename Superclass::DecoratedInput2ImagePixelType *>(this->ProcessObject::GetInput(1));
107  if (input != nullptr && itk::Math::AlmostEquals(input->Get(), typename TInputImage2::PixelType{}))
108  {
109  itkGenericExceptionMacro("The constant value used as denominator should not be set to zero");
110  }
111  }
112 };
113 
114 } // end namespace itk
115 
116 #endif
itk::DivideImageFilter
Pixel-wise division of two images.
Definition: itkDivideImageFilter.h:48
itk::DivideImageFilter::DivideImageFilter
DivideImageFilter()
Definition: itkDivideImageFilter.h:91
itk::BinaryGeneratorImageFilter
Implements pixel-wise generic operation of two images, or of an image and a constant.
Definition: itkBinaryGeneratorImageFilter.h:56
itk::SmartPointer< Self >
itkBinaryGeneratorImageFilter.h
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itkArithmeticOpsFunctors.h
FunctorType
Functor::Add2< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > FunctorType
Definition: itkAddImageFilter.h:97
itk::Concept::DivisionOperators
Definition: itkConceptChecking.h:475
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::Concept::Convertible
Definition: itkConceptChecking.h:216
itk::Math::AlmostEquals
bool AlmostEquals(T1 x1, T2 x2)
Provide consistent equality checks between values of potentially different scalar or complex types.
Definition: itkMath.h:688
itkNumericTraits.h
itk::Functor::Div
Definition: itkArithmeticOpsFunctors.h:133
itkMath.h
itk::ProcessObject::GetInput
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
itk::DivideImageFilter::VerifyPreconditions
void VerifyPreconditions() const override
Verifies that the process object has been configured correctly, that all required inputs are set,...
Definition: itkDivideImageFilter.h:101