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

itkIntensityWindowingImageFilter.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkIntensityWindowingImageFilter.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/09/10 14:28:50 $ 00007 Version: $Revision: 1.3 $ 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 __itkIntensityWindowingImageFilter_h 00018 #define __itkIntensityWindowingImageFilter_h 00019 00020 #include "itkUnaryFunctorImageFilter.h" 00021 00022 namespace itk 00023 { 00024 00025 // This functor class applies a linear transformation A.x + B inside a specified 00026 // range. Values below the range are mapped to a constant. Values over the range 00027 // are mapped to another constant. 00028 namespace Functor { 00029 00030 template< typename TInput, typename TOutput> 00031 class IntensityWindowingTransform 00032 { 00033 public: 00034 typedef typename NumericTraits< TInput >::RealType RealType; 00035 IntensityWindowingTransform() {} 00036 ~IntensityWindowingTransform() {} 00037 void SetFactor( RealType a ) { m_Factor = a; } 00038 void SetOffset( RealType b ) { m_Offset = b; } 00039 void SetOutputMinimum( TOutput min ) { m_OutputMinimum = min; } 00040 void SetOutputMaximum( TOutput max ) { m_OutputMaximum = max; } 00041 void SetWindowMinimum( TInput min ) { m_WindowMinimum = min; } 00042 void SetWindowMaximum( TInput max ) { m_WindowMaximum = max; } 00043 inline TOutput operator()( const TInput & x ) 00044 { 00045 if( x < m_WindowMinimum ) 00046 { 00047 return m_OutputMinimum; 00048 } 00049 if( x > m_WindowMaximum ) 00050 { 00051 return m_OutputMaximum; 00052 } 00053 const RealType value = static_cast<RealType>(x) * m_Factor + m_Offset; 00054 const TOutput result = static_cast<TOutput>( value ); 00055 return result; 00056 } 00057 private: 00058 RealType m_Factor; 00059 RealType m_Offset; 00060 TOutput m_OutputMaximum; 00061 TOutput m_OutputMinimum; 00062 TInput m_WindowMaximum; 00063 TInput m_WindowMinimum; 00064 }; 00065 00066 } // end namespace functor 00067 00068 00089 template <typename TInputImage, typename TOutputImage=TInputImage> 00090 class ITK_EXPORT IntensityWindowingImageFilter : 00091 public 00092 UnaryFunctorImageFilter<TInputImage,TOutputImage, 00093 Functor::IntensityWindowingTransform< 00094 typename TInputImage::PixelType, 00095 typename TOutputImage::PixelType> > 00096 { 00097 public: 00099 typedef IntensityWindowingImageFilter Self; 00100 typedef UnaryFunctorImageFilter<TInputImage,TOutputImage, 00101 Functor::IntensityWindowingTransform< 00102 typename TInputImage::PixelType, 00103 typename TOutputImage::PixelType> > Superclass; 00104 typedef SmartPointer<Self> Pointer; 00105 typedef SmartPointer<const Self> ConstPointer; 00106 00107 typedef typename TOutputImage::PixelType OutputPixelType; 00108 typedef typename TInputImage::PixelType InputPixelType; 00109 typedef typename NumericTraits<InputPixelType>::RealType RealType; 00110 00112 itkNewMacro(Self); 00113 00116 itkSetMacro( OutputMinimum, OutputPixelType ); 00117 itkSetMacro( OutputMaximum, OutputPixelType ); 00118 itkGetConstMacro( OutputMinimum, OutputPixelType ); 00119 itkGetConstMacro( OutputMaximum, OutputPixelType ); 00120 00123 itkSetMacro( WindowMinimum, InputPixelType ); 00124 itkSetMacro( WindowMaximum, InputPixelType ); 00125 itkGetConstMacro( WindowMinimum, InputPixelType ); 00126 itkGetConstMacro( WindowMaximum, InputPixelType ); 00127 00131 itkGetConstMacro( Scale, RealType ); 00132 itkGetConstMacro( Shift, RealType ); 00133 00135 void BeforeThreadedGenerateData(void); 00136 00138 void PrintSelf(std::ostream& os, Indent indent) const; 00139 00140 protected: 00141 IntensityWindowingImageFilter(); 00142 virtual ~IntensityWindowingImageFilter() {}; 00143 00144 private: 00145 IntensityWindowingImageFilter(const Self&); //purposely not implemented 00146 void operator=(const Self&); //purposely not implemented 00147 00148 RealType m_Scale; 00149 RealType m_Shift; 00150 00151 InputPixelType m_WindowMinimum; 00152 InputPixelType m_WindowMaximum; 00153 00154 OutputPixelType m_OutputMinimum; 00155 OutputPixelType m_OutputMaximum; 00156 00157 }; 00158 00159 00160 00161 } // end namespace itk 00162 00163 #ifndef ITK_MANUAL_INSTANTIATION 00164 #include "itkIntensityWindowingImageFilter.txx" 00165 #endif 00166 00167 #endif

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