ITK  5.2.0
Insight Toolkit
itkSquaredDifferenceImageFilter.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 itkSquaredDifferenceImageFilter_h
19 #define itkSquaredDifferenceImageFilter_h
20 
22 
23 namespace itk
24 {
54 namespace Functor
55 {
56 template <typename TInput1, typename TInput2, typename TOutput>
58 {
59 public:
60  SquaredDifference2() = default;
61  ~SquaredDifference2() = default;
62  bool
64  {
65  return false;
66  }
68 
69  bool
70  operator==(const SquaredDifference2 & other) const
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 
82  return static_cast<TOutput>(diff * diff);
83  }
84 };
85 } // namespace Functor
86 
87 template <typename TInputImage1, typename TInputImage2, typename TOutputImage>
88 class SquaredDifferenceImageFilter : public BinaryGeneratorImageFilter<TInputImage1, TInputImage2, TOutputImage>
89 {
90 public:
91  ITK_DISALLOW_COPY_AND_MOVE(SquaredDifferenceImageFilter);
92 
96 
99 
100  using FunctorType = Functor::SquaredDifference2<typename TInputImage1::PixelType,
101  typename TInputImage2::PixelType,
102  typename TOutputImage::PixelType>;
103 
105  itkNewMacro(Self);
106 
109 
110 #ifdef ITK_USE_CONCEPT_CHECKING
111  // Begin concept checking
115  // End concept checking
116 #endif
117 
118 protected:
120  {
121 #if !defined(ITK_WRAPPING_PARSER)
123 #endif
124  }
125  ~SquaredDifferenceImageFilter() override = default;
126 };
127 } // end namespace itk
128 
129 #endif
itk::SquaredDifferenceImageFilter
Implements pixel-wise the computation of squared difference.
Definition: itkSquaredDifferenceImageFilter.h:88
itk::Functor::SquaredDifference2::operator()
TOutput operator()(const TInput1 &A, const TInput2 &B) const
Definition: itkSquaredDifferenceImageFilter.h:76
itk::Functor::SquaredDifference2::operator!=
bool operator!=(const SquaredDifference2 &) const
Definition: itkSquaredDifferenceImageFilter.h:63
itk::SquaredDifferenceImageFilter::FunctorType
Functor::SquaredDifference2< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > FunctorType
Definition: itkSquaredDifferenceImageFilter.h:102
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::Functor::SquaredDifference2::SquaredDifference2
SquaredDifference2()=default
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::SquaredDifferenceImageFilter::SquaredDifferenceImageFilter
SquaredDifferenceImageFilter()
Definition: itkSquaredDifferenceImageFilter.h:119
itk::Functor::SquaredDifference2::~SquaredDifference2
~SquaredDifference2()=default
itk::Functor::SquaredDifference2::operator==
bool operator==(const SquaredDifference2 &other) const
Definition: itkSquaredDifferenceImageFilter.h:70
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::Concept::Convertible
Definition: itkConceptChecking.h:216
itk::Functor::SquaredDifference2
Definition: itkSquaredDifferenceImageFilter.h:57
itk::SquaredDifferenceImageFilter::~SquaredDifferenceImageFilter
~SquaredDifferenceImageFilter() override=default
itk::BinaryGeneratorImageFilter::SetFunctor
void SetFunctor(const std::function< ConstRefFunctionType > &f)
Definition: itkBinaryGeneratorImageFilter.h:150