ITK  4.4.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< class TInput1, class TInput2, class 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< class TInputImage1, class TInputImage2, class 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 
116  itkConceptMacro( Input1CovertibleToDoubleCheck,
118  itkConceptMacro( Input2ConvertibleToDoubleCheck,
120  itkConceptMacro( DoubleCovertibleToOutputCheck,
122 
124 #endif
125 
126 protected:
129 
130 private:
131  AbsoluteValueDifferenceImageFilter(const Self &); //purposely not implemented
132  void operator=(const Self &); //purposely not implemented
133 };
134 } // end namespace itk
135 
136 #endif
137