Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkRescaleIntensityImageFilter.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkRescaleIntensityImageFilter.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/11/14 17:29:13 $ 00007 Version: $Revision: 1.7 $ 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 __itkRescaleIntensityImageFilter_h 00018 #define __itkRescaleIntensityImageFilter_h 00019 00020 #include "itkUnaryFunctorImageFilter.h" 00021 00022 namespace itk 00023 { 00024 00025 // This functor class applies a linear transformation A.x + B 00026 // to input values. 00027 namespace Functor { 00028 00029 template< typename TInput, typename TOutput> 00030 class IntensityLinearTransform 00031 { 00032 public: 00033 typedef typename NumericTraits< TInput >::RealType RealType; 00034 IntensityLinearTransform() {} 00035 ~IntensityLinearTransform() {} 00036 void SetFactor( RealType a ) { m_Factor = a; } 00037 void SetOffset( RealType b ) { m_Offset = b; } 00038 void SetMinimum( TOutput min ) { m_Minimum = min; } 00039 void SetMaximum( TOutput max ) { m_Maximum = max; } 00040 inline TOutput operator()( const TInput & x ) 00041 { 00042 RealType value = static_cast<RealType>(x) * m_Factor + m_Offset; 00043 TOutput result = static_cast<TOutput>( value ); 00044 result = ( result > m_Maximum ) ? m_Maximum : result; 00045 result = ( result < m_Minimum ) ? m_Minimum : result; 00046 return result; 00047 } 00048 private: 00049 RealType m_Factor; 00050 RealType m_Offset; 00051 TOutput m_Maximum; 00052 TOutput m_Minimum; 00053 }; 00054 00055 } // end namespace functor 00056 00057 00073 template <typename TInputImage, typename TOutputImage=TInputImage> 00074 class ITK_EXPORT RescaleIntensityImageFilter : 00075 public 00076 UnaryFunctorImageFilter<TInputImage,TOutputImage, 00077 Functor::IntensityLinearTransform< 00078 typename TInputImage::PixelType, 00079 typename TOutputImage::PixelType> > 00080 { 00081 public: 00083 typedef RescaleIntensityImageFilter Self; 00084 typedef UnaryFunctorImageFilter<TInputImage,TOutputImage, 00085 Functor::IntensityLinearTransform< 00086 typename TInputImage::PixelType, 00087 typename TOutputImage::PixelType> > Superclass; 00088 typedef SmartPointer<Self> Pointer; 00089 typedef SmartPointer<const Self> ConstPointer; 00090 00091 typedef typename TOutputImage::PixelType OutputPixelType; 00092 typedef typename TInputImage::PixelType InputPixelType; 00093 typedef typename NumericTraits<InputPixelType>::RealType RealType; 00094 00096 itkNewMacro(Self); 00097 00098 itkSetMacro( OutputMinimum, OutputPixelType ); 00099 itkSetMacro( OutputMaximum, OutputPixelType ); 00100 itkGetConstMacro( OutputMinimum, OutputPixelType ); 00101 itkGetConstMacro( OutputMaximum, OutputPixelType ); 00102 00106 itkGetConstMacro( Scale, RealType ); 00107 itkGetConstMacro( Shift, RealType ); 00108 00111 itkGetConstMacro( InputMinimum, InputPixelType ); 00112 itkGetConstMacro( InputMaximum, InputPixelType ); 00113 00115 itkSetMacro( InputMaximum, InputPixelType ); 00116 itkSetMacro( InputMinimum, InputPixelType ); 00117 00119 void BeforeThreadedGenerateData(void); 00120 00122 void PrintSelf(std::ostream& os, Indent indent) const; 00123 00124 protected: 00125 RescaleIntensityImageFilter(); 00126 virtual ~RescaleIntensityImageFilter() {}; 00127 00128 private: 00129 RescaleIntensityImageFilter(const Self&); //purposely not implemented 00130 void operator=(const Self&); //purposely not implemented 00131 00132 RealType m_Scale; 00133 RealType m_Shift; 00134 00135 InputPixelType m_InputMinimum; 00136 InputPixelType m_InputMaximum; 00137 00138 OutputPixelType m_OutputMinimum; 00139 OutputPixelType m_OutputMaximum; 00140 00141 }; 00142 00143 00144 00145 } // end namespace itk 00146 00147 #ifndef ITK_MANUAL_INSTANTIATION 00148 #include "itkRescaleIntensityImageFilter.txx" 00149 #endif 00150 00151 #endif

Generated at Sun Apr 1 02:42:24 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000