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: 2002/09/03 15:09:43 $
00007   Version:   $Revision: 1.4 $
00008 
00009   Copyright (c) 2002 Insight 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 
00114 
00116   void BeforeThreadedGenerateData(void);
00117 
00119   void PrintSelf(std::ostream& os, Indent indent) const;
00120 
00121 protected:
00122   RescaleIntensityImageFilter();
00123   virtual ~RescaleIntensityImageFilter() {};
00124 
00125 private:
00126   RescaleIntensityImageFilter(const Self&); //purposely not implemented
00127   void operator=(const Self&); //purposely not implemented
00128 
00129   RealType m_Scale;
00130   RealType m_Shift;
00131 
00132   InputPixelType        m_InputMinimum;
00133   InputPixelType        m_InputMaximum;
00134 
00135   OutputPixelType       m_OutputMinimum;
00136   OutputPixelType       m_OutputMaximum;
00137 
00138 };
00139 
00140 
00141   
00142 } // end namespace itk
00143   
00144 #ifndef ITK_MANUAL_INSTANTIATION
00145 #include "itkRescaleIntensityImageFilter.txx"
00146 #endif
00147   
00148 #endif

Generated at Wed Mar 12 01:13:10 2003 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000