ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkConstrainedValueDifferenceImageFilter.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 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:
64  {
65  return false;
66  }
67 
68  bool operator==(const ConstrainedValueDifference & other) const
69  {
70  return !( *this != other );
71  }
72 
73  inline TOutput operator()(const TInput1 & A,
74  const TInput2 & B) const
75  {
76  const double dA = static_cast< double >( A );
77  const double dB = static_cast< double >( B );
78  const double diff = dA - dB;
79  const double cdiff1 = diff > NumericTraits< TOutput >::NonpositiveMin() ?
81  const double cdiff2 = cdiff1 < NumericTraits< TOutput >::max() ?
83 
84  return static_cast< TOutput >( cdiff2 );
85  }
86 };
87 }
88 
89 template< typename TInputImage1, typename TInputImage2, typename TOutputImage >
91  public
92  BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage,
93  Functor::ConstrainedValueDifference<
94  typename TInputImage1::PixelType,
95  typename TInputImage2::PixelType,
96  typename TOutputImage::PixelType > >
97 {
98 public:
101  typedef BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage,
103  typename TInputImage1::PixelType,
104  typename TInputImage2::PixelType,
105  typename TOutputImage::PixelType > >
109 
111  itkNewMacro(Self);
112 
116 
117 #ifdef ITK_USE_CONCEPT_CHECKING
118  // Begin concept checking
119  itkConceptMacro( Input1ConvertibleToDoubleCheck,
121  itkConceptMacro( Input2ConvertibleToDoubleCheck,
123  itkConceptMacro( DoubleConvertibleToOutputCheck,
125  itkConceptMacro( DoubleGreaterThanOutputCheck,
127  // End concept checking
128 #endif
129 
130 protected:
133 
134 private:
135  ConstrainedValueDifferenceImageFilter(const Self &); //purposely not
136  // implemented
137  void operator=(const Self &); //purposely not
138 
139  // implemented
140 };
141 } // end namespace itk
142 
143 #endif
BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage, Functor::ConstrainedValueDifference< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > > Superclass
Base class for all process objects that output image data.
TOutput operator()(const TInput1 &A, const TInput2 &B) const
Implements pixel-wise the computation of constrained value difference.
bool operator!=(const ConstrainedValueDifference &) const
Define additional traits for native types such as int or float.
#define itkConceptMacro(name, concept)
Implements pixel-wise generic operation of two images, or of an image and a constant.
bool operator==(const ConstrainedValueDifference &other) const