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: 2004/11/04 20:40:38 $
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 __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   itkGetConstReferenceMacro( OutputMinimum, OutputPixelType );
00119   itkGetConstReferenceMacro( OutputMaximum, OutputPixelType );
00120 
00123   itkSetMacro( WindowMinimum, InputPixelType );
00124   itkSetMacro( WindowMaximum, InputPixelType );
00125   itkGetConstReferenceMacro( WindowMinimum, InputPixelType );
00126   itkGetConstReferenceMacro( WindowMaximum, InputPixelType );
00127 
00132   void SetWindowLevel(const InputPixelType& window,
00133                       const InputPixelType& level);
00134   InputPixelType GetWindow() const;
00135   InputPixelType GetLevel() const;
00136   
00140   itkGetConstReferenceMacro( Scale, RealType );
00141   itkGetConstReferenceMacro( Shift, RealType );
00142 
00144   void BeforeThreadedGenerateData(void);
00145 
00147   void PrintSelf(std::ostream& os, Indent indent) const;
00148 
00149 protected:
00150   IntensityWindowingImageFilter();
00151   virtual ~IntensityWindowingImageFilter() {};
00152 
00153 private:
00154   IntensityWindowingImageFilter(const Self&); //purposely not implemented
00155   void operator=(const Self&); //purposely not implemented
00156 
00157   RealType m_Scale;
00158   RealType m_Shift;
00159 
00160   InputPixelType        m_WindowMinimum;
00161   InputPixelType        m_WindowMaximum;
00162 
00163   OutputPixelType       m_OutputMinimum;
00164   OutputPixelType       m_OutputMaximum;
00165 
00166 };
00167 
00168 
00169   
00170 } // end namespace itk
00171   
00172 #ifndef ITK_MANUAL_INSTANTIATION
00173 #include "itkIntensityWindowingImageFilter.txx"
00174 #endif
00175   
00176 #endif

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