ITK  5.4.0
Insight Toolkit
itkConstrainedValueDifferenceImageFilter.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 itkConstrainedValueDifferenceImageFilter_h
19#define itkConstrainedValueDifferenceImageFilter_h
20
22#include "itkNumericTraits.h"
23
24namespace itk
25{
55namespace Functor
56{
57template <typename TInput1, typename TInput2, typename TOutput>
59{
60public:
61 bool
63 {
64 return true;
65 }
66
68
69 inline TOutput
70 operator()(const TInput1 & A, const TInput2 & B) const
71 {
72 const auto dA = static_cast<double>(A);
73 const auto dB = static_cast<double>(B);
74 const double diff = dA - dB;
75 const double cdiff1 =
77 const double cdiff2 = cdiff1 < NumericTraits<TOutput>::max() ? cdiff1 : NumericTraits<TOutput>::max();
78
79 return static_cast<TOutput>(cdiff2);
80 }
81};
82} // namespace Functor
83
84template <typename TInputImage1, typename TInputImage2, typename TOutputImage>
86 : public BinaryGeneratorImageFilter<TInputImage1, TInputImage2, TOutputImage>
87{
88public:
89 ITK_DISALLOW_COPY_AND_MOVE(ConstrainedValueDifferenceImageFilter);
90
96 using FunctorType = Functor::ConstrainedValueDifference<typename TInputImage1::PixelType,
97 typename TInputImage2::PixelType,
98 typename TOutputImage::PixelType>;
99
101 itkNewMacro(Self);
102
104 itkOverrideGetNameOfClassMacro(ConstrainedValueDifferenceImageFilter);
105
106#ifdef ITK_USE_CONCEPT_CHECKING
107 // Begin concept checking
111 itkConceptMacro(DoubleGreaterThanOutputCheck,
113 // End concept checking
114#endif
115
116protected:
118 {
119#if !defined(ITK_WRAPPING_PARSER)
121#endif
122 }
123
125};
126} // end namespace itk
127
128#endif
Implements pixel-wise generic operation of two images, or of an image and a constant.
void SetFunctor(const std::function< ConstRefFunctionType > &f)
Implements pixel-wise the computation of constrained value difference.
Functor::ConstrainedValueDifference< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > FunctorType
~ConstrainedValueDifferenceImageFilter() override=default
TOutput operator()(const TInput1 &A, const TInput2 &B) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(ConstrainedValueDifference)
bool operator==(const ConstrainedValueDifference &) const
Base class for all process objects that output image data.
Define additional traits for native types such as int or float.
static constexpr T NonpositiveMin()
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....