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
26namespace itk
27{
28
47template <typename TInputImage1, typename TInputImage2, typename TOutputImage>
48class ITK_TEMPLATE_EXPORT DivideImageFilter
49 : public BinaryGeneratorImageFilter<TInputImage1, TInputImage2, TOutputImage>
50{
51public:
52 ITK_DISALLOW_COPY_AND_MOVE(DivideImageFilter);
53
58
63
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
90protected:
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
Implements pixel-wise generic operation of two images, or of an image and a constant.
Pixel-wise division of two images.
void VerifyPreconditions() const override
Verifies that the process object has been configured correctly, that all required inputs are set,...
~DivideImageFilter() override=default
Base class for all process objects that output image data.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
Functor::Add2< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > FunctorType
#define itkConceptMacro(name, concept)
bool AlmostEquals(T1 x1, T2 x2)
Provide consistent equality checks between values of potentially different scalar or complex types.
Definition: itkMath.h:688
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....