00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkAbsImageAdaptor.h,v $ 00005 Language: C++ 00006 Date: $Date: 2006-03-19 04:36:58 $ 00007 Version: $Revision: 1.4 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkAbsImageAdaptor_h 00018 #define __itkAbsImageAdaptor_h 00019 00020 #include <itkImageAdaptor.h> 00021 00022 namespace itk 00023 { 00024 00025 namespace Accessor { 00036 template <class TInternalType, class TExternalType > 00037 class ITK_EXPORT AbsPixelAccessor 00038 { 00039 public: 00042 typedef TExternalType ExternalType; 00043 00046 typedef TInternalType InternalType; 00047 00048 static inline void Set(TInternalType & output, const TExternalType & input) 00049 {output = (TInternalType)( 00050 (input > NumericTraits<TExternalType>::Zero) ? input : -input );} 00051 00052 static inline TExternalType Get( const TInternalType & input ) 00053 {return (TExternalType) ( 00054 (input > NumericTraits<TInternalType>::Zero) ? input : -input );} 00055 }; 00056 00057 } // end namespace Accessor 00058 00067 template <class TImage, class TOutputPixelType> 00068 class ITK_EXPORT AbsImageAdaptor : public 00069 ImageAdaptor<TImage, 00070 Accessor::AbsPixelAccessor< 00071 typename TImage::PixelType, 00072 TOutputPixelType> > 00073 { 00074 public: 00076 typedef AbsImageAdaptor Self; 00077 typedef ImageAdaptor<TImage, Accessor::AbsPixelAccessor< 00078 typename TImage::PixelType, 00079 TOutputPixelType> > Superclass; 00080 typedef SmartPointer<Self> Pointer; 00081 typedef SmartPointer<const Self> ConstPointer; 00082 00084 itkNewMacro(Self); 00085 00087 itkTypeMacro( AbsImageAdaptor, ImageAdaptor ); 00088 00089 protected: 00090 AbsImageAdaptor() {} 00091 virtual ~AbsImageAdaptor() {} 00092 00093 private: 00094 AbsImageAdaptor(const Self&); //purposely not implemented 00095 void operator=(const Self&); //purposely not implemented 00096 00097 }; 00098 00099 } // end namespace itk 00100 00101 #endif 00102