ITK  5.4.0
Insight Toolkit
itkAbsoluteValueDifferenceImageFilter.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 itkAbsoluteValueDifferenceImageFilter_h
19#define itkAbsoluteValueDifferenceImageFilter_h
20
22#include "itkConceptChecking.h"
23
24namespace itk
25{
55namespace Functor
56{
57template <typename TInput1, typename TInput2, typename TOutput>
59{
60public:
61 bool
63 {
64 return true;
65 }
69
70 inline TOutput
71 operator()(const TInput1 & A, const TInput2 & B) const
72 {
73 const auto dA = static_cast<double>(A);
74 const auto dB = static_cast<double>(B);
75 const double diff = dA - dB;
76 const double absdiff = (diff > 0.0) ? diff : -diff;
77
78 return static_cast<TOutput>(absdiff);
79 }
80};
81} // namespace Functor
82
83template <typename TInputImage1, typename TInputImage2, typename TOutputImage>
84class ITK_TEMPLATE_EXPORT AbsoluteValueDifferenceImageFilter
85 : public BinaryGeneratorImageFilter<TInputImage1, TInputImage2, TOutputImage>
86{
87public:
88 ITK_DISALLOW_COPY_AND_MOVE(AbsoluteValueDifferenceImageFilter);
89
93
96
97
98 using FunctorType = Functor::AbsoluteValueDifference2<typename TInputImage1::PixelType,
99 typename TInputImage2::PixelType,
100 typename TOutputImage::PixelType>;
101
103 itkNewMacro(Self);
104
106 itkOverrideGetNameOfClassMacro(AbsoluteValueDifferenceImageFilter);
107
108#ifdef ITK_USE_CONCEPT_CHECKING
109 // Begin concept checking
113 // End concept checking
114#endif
115
116protected:
118 {
119#if !defined(ITK_WRAPPING_PARSER)
120 Superclass::SetFunctor(FunctorType());
121#endif
122 }
124};
125} // end namespace itk
126
127#endif
Implements pixel-wise the computation of absolute value difference.
~AbsoluteValueDifferenceImageFilter() override=default
Implements pixel-wise generic operation of two images, or of an image and a constant.
bool operator==(const AbsoluteValueDifference2 &) const
TOutput operator()(const TInput1 &A, const TInput2 &B) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(AbsoluteValueDifference2)
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...
Functor::Add2< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > FunctorType
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....