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: 2004/11/29 22:18:43 $
00007   Version:   $Revision: 1.11 $
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 
00083 template <typename  TInputImage, typename  TOutputImage=TInputImage>
00084 class ITK_EXPORT RescaleIntensityImageFilter :
00085     public
00086 UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00087                         Functor::IntensityLinearTransform< 
00088   typename TInputImage::PixelType, 
00089   typename TOutputImage::PixelType>   >
00090 {
00091 public:
00093   typedef RescaleIntensityImageFilter  Self;
00094   typedef UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00095                                   Functor::IntensityLinearTransform< 
00096     typename TInputImage::PixelType, 
00097     typename TOutputImage::PixelType> >  Superclass;
00098   typedef SmartPointer<Self>   Pointer;
00099   typedef SmartPointer<const Self>  ConstPointer;
00100 
00101   typedef typename TOutputImage::PixelType OutputPixelType;
00102   typedef typename TInputImage::PixelType  InputPixelType;
00103   typedef typename NumericTraits<InputPixelType>::RealType RealType;
00104 
00106   itkNewMacro(Self);
00107   
00108   itkSetMacro( OutputMinimum, OutputPixelType );
00109   itkSetMacro( OutputMaximum, OutputPixelType );
00110   itkGetConstReferenceMacro( OutputMinimum, OutputPixelType );
00111   itkGetConstReferenceMacro( OutputMaximum, OutputPixelType );
00112 
00116   itkGetConstReferenceMacro( Scale, RealType );
00117   itkGetConstReferenceMacro( Shift, RealType );
00118 
00121   itkGetConstReferenceMacro( InputMinimum, InputPixelType );
00122   itkGetConstReferenceMacro( InputMaximum, InputPixelType );
00123 
00125   void BeforeThreadedGenerateData(void);
00126 
00128   void PrintSelf(std::ostream& os, Indent indent) const;
00129 
00130 protected:
00131   RescaleIntensityImageFilter();
00132   virtual ~RescaleIntensityImageFilter() {};
00133 
00134 private:
00135   RescaleIntensityImageFilter(const Self&); //purposely not implemented
00136   void operator=(const Self&); //purposely not implemented
00137 
00138   RealType m_Scale;
00139   RealType m_Shift;
00140 
00141   InputPixelType        m_InputMinimum;
00142   InputPixelType        m_InputMaximum;
00143 
00144   OutputPixelType       m_OutputMinimum;
00145   OutputPixelType       m_OutputMaximum;
00146 
00147 };
00148 
00149 
00150   
00151 } // end namespace itk
00152   
00153 #ifndef ITK_MANUAL_INSTANTIATION
00154 #include "itkRescaleIntensityImageFilter.txx"
00155 #endif
00156   
00157 #endif

Generated at Wed May 24 23:58:36 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000