ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkAbsImageFilter.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 __itkAbsImageFilter_h
19 #define __itkAbsImageFilter_h
20 
22 #include "itkConceptChecking.h"
23 
24 namespace itk
25 {
26 namespace Functor
27 {
32 template< class TInput, class TOutput >
33 class Abs
34 {
35 public:
36  Abs() {}
37  ~Abs() {}
38  bool operator!=(const Abs &) const
39  {
40  return false;
41  }
42 
43  bool operator==(const Abs & other) const
44  {
45  return !( *this != other );
46  }
47 
48  inline TOutput operator()(const TInput & A) const
49  {
50  return static_cast<TOutput>( vnl_math_abs( A ) );
51  }
52 };
53 }
54 
68 template< class TInputImage, class TOutputImage >
69 class ITK_EXPORT AbsImageFilter:
70  public
71  UnaryFunctorImageFilter< TInputImage, TOutputImage,
72  Functor::Abs<
73  typename TInputImage::PixelType,
74  typename TOutputImage::PixelType > >
75 {
76 public:
79  typedef UnaryFunctorImageFilter< TInputImage, TOutputImage,
80  Functor::Abs< typename TInputImage::PixelType,
81  typename TOutputImage::PixelType > > Superclass;
84 
86  itkNewMacro(Self);
87 
89  itkTypeMacro(AbsImageFilter,
91 
92  typedef typename TInputImage::PixelType InputPixelType;
93  typedef typename TOutputImage::PixelType OutputPixelType;
94 
95 #ifdef ITK_USE_CONCEPT_CHECKING
96 
97  itkConceptMacro( ConvertibleCheck,
99  itkConceptMacro( InputGreaterThanIntCheck,
101 
103 #endif
104 protected:
106  virtual ~AbsImageFilter() {}
107 private:
108  AbsImageFilter(const Self &); //purposely not implemented
109  void operator=(const Self &); //purposely not implemented
110 };
111 } // end namespace itk
113 
114 #endif
115