ITK  4.9.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:
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 double dA = static_cast< double >( A );
76  const double 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  BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage,
89  Functor::AbsoluteValueDifference2<
90  typename TInputImage1::PixelType,
91  typename TInputImage2::PixelType,
92  typename TOutputImage::PixelType > >
93 {
94 public:
97  typedef BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage,
99  typename TInputImage1::PixelType,
100  typename TInputImage2::PixelType,
101  typename TOutputImage::PixelType >
103 
106 
108  itkNewMacro(Self);
109 
113 
114 #ifdef ITK_USE_CONCEPT_CHECKING
115  // Begin concept checking
116  itkConceptMacro( Input1CovertibleToDoubleCheck,
118  itkConceptMacro( Input2ConvertibleToDoubleCheck,
120  itkConceptMacro( DoubleCovertibleToOutputCheck,
122  // End concept checking
123 #endif
124 
125 protected:
128 
129 private:
130  AbsoluteValueDifferenceImageFilter(const Self &) ITK_DELETE_FUNCTION;
131  void operator=(const Self &) ITK_DELETE_FUNCTION;
132 };
133 } // end namespace itk
134 
135 #endif
bool operator==(const AbsoluteValueDifference2 &other) const
Implements pixel-wise the computation of absolute value difference.
Base class for all process objects that output image data.
bool operator!=(const AbsoluteValueDifference2 &) const
BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage, Functor::AbsoluteValueDifference2< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > > Superclass
#define itkConceptMacro(name, concept)
Implements pixel-wise generic operation of two images, or of an image and a constant.
TOutput operator()(const TInput1 &A, const TInput2 &B) const