ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkAbsImageFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkAbsImageFilter_h
00019 #define __itkAbsImageFilter_h
00020 
00021 #include "itkUnaryFunctorImageFilter.h"
00022 #include "itkConceptChecking.h"
00023 
00024 namespace itk
00025 {
00026 namespace Functor
00027 {
00032 template< class TInput, class TOutput >
00033 class Abs
00034 {
00035 public:
00036   Abs() {}
00037   ~Abs() {}
00038   bool operator!=(const Abs &) const
00039   {
00040     return false;
00041   }
00042 
00043   bool operator==(const Abs & other) const
00044   {
00045     return !( *this != other );
00046   }
00047 
00048   inline TOutput operator()(const TInput & A) const
00049   {
00050     return static_cast<TOutput>( vnl_math_abs( A ) );
00051   }
00052 };
00053 }
00054 
00068 template< class TInputImage, class TOutputImage >
00069 class ITK_EXPORT AbsImageFilter:
00070   public
00071   UnaryFunctorImageFilter< TInputImage, TOutputImage,
00072                            Functor::Abs<
00073                              typename TInputImage::PixelType,
00074                              typename TOutputImage::PixelType >   >
00075 {
00076 public:
00078   typedef AbsImageFilter Self;
00079   typedef UnaryFunctorImageFilter< TInputImage, TOutputImage,
00080                                    Functor::Abs< typename TInputImage::PixelType,
00081                                                  typename TOutputImage::PixelType > >  Superclass;
00082   typedef SmartPointer< Self >       Pointer;
00083   typedef SmartPointer< const Self > ConstPointer;
00084 
00086   itkNewMacro(Self);
00087 
00089   itkTypeMacro(AbsImageFilter,
00090                UnaryFunctorImageFilter);
00091 
00092   typedef typename TInputImage::PixelType     InputPixelType;
00093   typedef typename TOutputImage::PixelType    OutputPixelType;
00094 
00095 #ifdef ITK_USE_CONCEPT_CHECKING
00096 
00097   itkConceptMacro( ConvertibleCheck,
00098                    ( Concept::Convertible< InputPixelType, OutputPixelType > ) );
00099   itkConceptMacro( InputGreaterThanIntCheck,
00100                    ( Concept::GreaterThanComparable< InputPixelType, InputPixelType > ) );
00101 
00103 #endif
00104 protected:
00105   AbsImageFilter() {}
00106   virtual ~AbsImageFilter() {}
00107 private:
00108   AbsImageFilter(const Self &); //purposely not implemented
00109   void operator=(const Self &); //purposely not implemented
00110 };
00111 } // end namespace itk
00113 
00114 #endif
00115