ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkAbsoluteValueDifferenceImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 itkAbsoluteValueDifferenceImageFilter_h
19 #define itkAbsoluteValueDifferenceImageFilter_h
20 
22 #include "itkConceptChecking.h"
23 
24 namespace itk
25 {
54 namespace Functor
55 {
56 template< typename TInput1, typename TInput2, typename TOutput >
58 {
59 public:
60  AbsoluteValueDifference2() = default;
61  ~AbsoluteValueDifference2() = default;
63  {
64  return false;
65  }
66 
67  bool operator==(const AbsoluteValueDifference2 & other) const
68  {
69  return !( *this != other );
70  }
71 
72  inline TOutput operator()(const TInput1 & A,
73  const TInput2 & B) const
74  {
75  const auto dA = static_cast< double >( A );
76  const auto dB = static_cast< double >( B );
77  const double diff = dA - dB;
78  const double absdiff = ( diff > 0.0 ) ? diff : -diff;
79 
80  return static_cast< TOutput >( absdiff );
81  }
82 };
83 }
84 
85 template< typename TInputImage1, typename TInputImage2, typename TOutputImage >
87  public
88  BinaryGeneratorImageFilter< TInputImage1, TInputImage2, TOutputImage >
89 {
90 public:
91  ITK_DISALLOW_COPY_AND_ASSIGN(AbsoluteValueDifferenceImageFilter);
92 
96 
99 
100 
101  using FunctorType = Functor::AbsoluteValueDifference2< typename TInputImage1::PixelType,
102  typename TInputImage2::PixelType,
103  typename TOutputImage::PixelType >;
104 
106  itkNewMacro(Self);
107 
111 
112 #ifdef ITK_USE_CONCEPT_CHECKING
113  // Begin concept checking
114  itkConceptMacro( Input1CovertibleToDoubleCheck,
116  itkConceptMacro( Input2ConvertibleToDoubleCheck,
118  itkConceptMacro( DoubleCovertibleToOutputCheck,
120  // End concept checking
121 #endif
122 
123 protected:
125  {
126 #if !defined( ITK_WRAPPING_PARSER )
128 #endif
129  }
130  ~AbsoluteValueDifferenceImageFilter() override = default;
131 };
132 } // end namespace itk
133 
134 #endif
bool operator==(const AbsoluteValueDifference2 &other) const
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Implements pixel-wise the computation of absolute value difference.
Base class for all process objects that output image data.
Functor::AbsoluteValueDifference2< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > FunctorType
bool operator!=(const AbsoluteValueDifference2 &) const
Implements pixel-wise generic operation of two images, or of an image and a constant.
void SetFunctor(const std::function< ConstRefFunctionType > &f)
#define itkConceptMacro(name, concept)
~AbsoluteValueDifferenceImageFilter() override=default
TOutput operator()(const TInput1 &A, const TInput2 &B) const