00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkComplexToModulusImageAdaptor.h,v $ 00005 Language: C++ 00006 Date: $Date: 2006-04-01 13:44:21 $ 00007 Version: $Revision: 1.5 $ 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 __itkComplexToModulusImageAdaptor_h 00018 #define __itkComplexToModulusImageAdaptor_h 00019 00020 #include <itkImageAdaptor.h> 00021 #include <complex> 00022 00023 namespace itk 00024 { 00025 00026 namespace Accessor { 00038 template <class TInternalType, class TExternalType > 00039 class ITK_EXPORT ComplexToModulusPixelAccessor 00040 { 00041 public: 00044 typedef TExternalType ExternalType; 00045 00048 typedef TInternalType InternalType; 00049 00050 static inline void Set(TInternalType & output, const TExternalType & input) 00051 {output = (TInternalType)(input);} 00052 00053 static inline TExternalType Get( const TInternalType & input ) 00054 {return (TExternalType)( vcl_sqrt(input.real() * input.real() + 00055 input.imag() * input.imag() ) ); } 00056 }; 00057 00058 } // end namespace Accessor 00059 00069 template <class TImage, class TOutputPixelType> 00070 class ITK_EXPORT ComplexToModulusImageAdaptor : public 00071 ImageAdaptor<TImage, 00072 Accessor::ComplexToModulusPixelAccessor< 00073 typename TImage::PixelType, 00074 TOutputPixelType> > 00075 { 00076 public: 00078 typedef ComplexToModulusImageAdaptor Self; 00079 typedef ImageAdaptor<TImage, Accessor::ComplexToModulusPixelAccessor< 00080 typename TImage::PixelType, 00081 TOutputPixelType> > Superclass; 00082 typedef SmartPointer<Self> Pointer; 00083 typedef SmartPointer<const Self> ConstPointer; 00084 00086 itkNewMacro(Self); 00087 00089 itkTypeMacro( ComplexToModulusImageAdaptor, ImageAdaptor ); 00090 00091 protected: 00092 ComplexToModulusImageAdaptor() {} 00093 virtual ~ComplexToModulusImageAdaptor() {} 00094 00095 private: 00096 ComplexToModulusImageAdaptor(const Self&); //purposely not implemented 00097 void operator=(const Self&); //purposely not implemented 00098 00099 }; 00100 00101 } // end namespace itk 00102 00103 #endif 00104