ITK  5.2.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  * 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 itkConstrainedValueDifferenceImageFilter_h
19 #define itkConstrainedValueDifferenceImageFilter_h
20 
22 #include "itkNumericTraits.h"
23 
24 namespace itk
25 {
55 namespace Functor
56 {
57 template <typename TInput1, typename TInput2, typename TOutput>
59 {
60 public:
61  ConstrainedValueDifference() = default;
62  ~ConstrainedValueDifference() = default;
63  bool
65  {
66  return false;
67  }
68 
69  bool
71  {
72  return !(*this != other);
73  }
74 
75  inline TOutput
76  operator()(const TInput1 & A, const TInput2 & B) const
77  {
78  const auto dA = static_cast<double>(A);
79  const auto dB = static_cast<double>(B);
80  const double diff = dA - dB;
81  const double cdiff1 =
83  const double cdiff2 = cdiff1 < NumericTraits<TOutput>::max() ? cdiff1 : NumericTraits<TOutput>::max();
84 
85  return static_cast<TOutput>(cdiff2);
86  }
87 };
88 } // namespace Functor
89 
90 template <typename TInputImage1, typename TInputImage2, typename TOutputImage>
92  : public BinaryGeneratorImageFilter<TInputImage1, TInputImage2, TOutputImage>
93 {
94 public:
95  ITK_DISALLOW_COPY_AND_MOVE(ConstrainedValueDifferenceImageFilter);
96 
102  using FunctorType = Functor::ConstrainedValueDifference<typename TInputImage1::PixelType,
103  typename TInputImage2::PixelType,
104  typename TOutputImage::PixelType>;
105 
107  itkNewMacro(Self);
108 
111 
112 #ifdef ITK_USE_CONCEPT_CHECKING
113  // Begin concept checking
117  itkConceptMacro(DoubleGreaterThanOutputCheck,
119  // End concept checking
120 #endif
121 
122 protected:
124  {
125 #if !defined(ITK_WRAPPING_PARSER)
127 #endif
128  }
129 
130  ~ConstrainedValueDifferenceImageFilter() override = default;
131 };
132 } // end namespace itk
133 
134 #endif
itk::Functor::ConstrainedValueDifference::operator==
bool operator==(const ConstrainedValueDifference &other) const
Definition: itkConstrainedValueDifferenceImageFilter.h:70
itk::Functor::ConstrainedValueDifference::~ConstrainedValueDifference
~ConstrainedValueDifference()=default
itk::Functor::ConstrainedValueDifference::operator!=
bool operator!=(const ConstrainedValueDifference &) const
Definition: itkConstrainedValueDifferenceImageFilter.h:64
itk::Concept::GreaterThanComparable
Definition: itkConceptChecking.h:284
itk::NumericTraits::NonpositiveMin
static constexpr T NonpositiveMin()
Definition: itkNumericTraits.h:97
itk::BinaryGeneratorImageFilter
Implements pixel-wise generic operation of two images, or of an image and a constant.
Definition: itkBinaryGeneratorImageFilter.h:56
itk::SmartPointer< Self >
itk::ConstrainedValueDifferenceImageFilter::FunctorType
Functor::ConstrainedValueDifference< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > FunctorType
Definition: itkConstrainedValueDifferenceImageFilter.h:104
itk::ConstrainedValueDifferenceImageFilter::ConstrainedValueDifferenceImageFilter
ConstrainedValueDifferenceImageFilter()
Definition: itkConstrainedValueDifferenceImageFilter.h:123
itkBinaryGeneratorImageFilter.h
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::Functor::ConstrainedValueDifference::ConstrainedValueDifference
ConstrainedValueDifference()=default
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:58
itk::ConstrainedValueDifferenceImageFilter::~ConstrainedValueDifferenceImageFilter
~ConstrainedValueDifferenceImageFilter() override=default
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:138
itk::Functor::ConstrainedValueDifference
Definition: itkConstrainedValueDifferenceImageFilter.h:58
itk::Concept::Convertible
Definition: itkConceptChecking.h:216
itk::ConstrainedValueDifferenceImageFilter
Implements pixel-wise the computation of constrained value difference.
Definition: itkConstrainedValueDifferenceImageFilter.h:91
itkNumericTraits.h
itk::Functor::ConstrainedValueDifference::operator()
TOutput operator()(const TInput1 &A, const TInput2 &B) const
Definition: itkConstrainedValueDifferenceImageFilter.h:76
itk::BinaryGeneratorImageFilter::SetFunctor
void SetFunctor(const std::function< ConstRefFunctionType > &f)
Definition: itkBinaryGeneratorImageFilter.h:150