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

itkColormapFunctor.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkColormapFunctor.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-05-21 20:16:56 $
00007   Version:   $Revision: 1.6 $
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 __itkColormapFunctor_h
00018 #define __itkColormapFunctor_h
00019 
00020 #include "itkLightObject.h"
00021 #include "itkNumericTraits.h"
00022 #include "itkRGBPixel.h"
00023 
00024 namespace itk {
00025 
00026 namespace Functor {
00027 
00042 template< class TScalar, class TRGBPixel >
00043 class ITK_EXPORT ColormapFunctor : public Object
00044 {
00045 public:
00046 
00047   typedef ColormapFunctor                          Self;
00048   typedef Object                                   Superclass;
00049   typedef SmartPointer<Self>                       Pointer;
00050   typedef SmartPointer<const Self>                 ConstPointer;
00051 
00053   itkTypeMacro(ColormapFunctor, Object);
00054 
00055   typedef TRGBPixel                                     RGBPixelType;
00056   typedef typename TRGBPixel::ComponentType             RGBComponentType;
00057   typedef TScalar                                       ScalarType;
00058   typedef typename NumericTraits<ScalarType>::RealType  RealType;
00059 
00060   itkSetMacro( MinimumRGBComponentValue, RGBComponentType );
00061   itkGetConstMacro( MinimumRGBComponentValue, RGBComponentType );
00062 
00063   itkSetMacro( MaximumRGBComponentValue, RGBComponentType );
00064   itkGetConstMacro( MaximumRGBComponentValue, RGBComponentType );
00065 
00066   itkSetMacro( MinimumInputValue, ScalarType );
00067   itkGetConstMacro( MinimumInputValue, ScalarType );
00068 
00069   itkSetMacro( MaximumInputValue, ScalarType );
00070   itkGetConstMacro( MaximumInputValue, ScalarType );
00071 
00072   virtual bool operator!=( const ColormapFunctor & ) const
00073     {
00074     return false;
00075     }
00076   virtual bool operator==( const ColormapFunctor & other ) const
00077     {
00078     return !(*this != other);
00079     }
00080 
00081   virtual RGBPixelType operator()( const ScalarType & ) const = 0;
00082 
00083 protected:
00084   ColormapFunctor()
00085     {
00086     this->m_MinimumInputValue = NumericTraits<TScalar>::min();
00087     this->m_MaximumInputValue = NumericTraits<TScalar>::max();
00088     this->m_MinimumRGBComponentValue = NumericTraits<RGBComponentType>::min();
00089     this->m_MaximumRGBComponentValue = NumericTraits<RGBComponentType>::max();
00090     }
00091 
00092   ~ColormapFunctor() {};
00093 
00094 
00098   RealType RescaleInputValue( ScalarType v ) const
00099     {
00100     RealType d = static_cast<RealType>( this->m_MaximumInputValue - this->m_MinimumInputValue );
00101     RealType value = ( static_cast<RealType>( v )
00102       - static_cast<RealType>( this->m_MinimumInputValue ) ) / d;
00103     value = vnl_math_max( 0.0, value );
00104     value = vnl_math_min( 1.0, value );
00105     return value;
00106     }
00108 
00112   RGBComponentType RescaleRGBComponentValue( RealType v ) const
00113     {
00114     RealType d = static_cast<RealType>( m_MaximumRGBComponentValue - m_MinimumRGBComponentValue );
00115     const RGBComponentType rescaled = 
00116       static_cast<RGBComponentType>( d * v ) + this->m_MinimumRGBComponentValue;
00117     return rescaled;
00118     }
00120 
00121   void PrintSelf(std::ostream& os, Indent indent) const
00122     {
00123     Superclass::PrintSelf(os, indent);
00124 
00125     os << indent << "Minimum RGB Component Value: "
00126        << static_cast<typename NumericTraits<RGBComponentType>::PrintType>(
00127          this->GetMinimumRGBComponentValue()) << std::endl;
00128     os << indent << "Maximum RGB Component Value: "
00129        << static_cast<typename NumericTraits<RGBComponentType>::PrintType>(
00130          this->GetMaximumRGBComponentValue()) << std::endl;
00131     os << indent << "Minimum Input Value: "
00132        << static_cast<typename NumericTraits<ScalarType>::PrintType>(
00133          this->GetMinimumInputValue()) << std::endl;
00134     os << indent << "Maximum Input Value: "
00135        << static_cast<typename NumericTraits<ScalarType>::PrintType>(
00136          this->GetMaximumInputValue()) << std::endl;
00137     }
00138 
00139 private:
00140   ColormapFunctor(const Self&); //purposely not implemented
00141   void operator=(const Self&); //purposely not implemented
00142 
00143   ScalarType            m_MinimumInputValue;
00144   ScalarType            m_MaximumInputValue;
00145 
00146   RGBComponentType      m_MinimumRGBComponentValue;
00147   RGBComponentType      m_MaximumRGBComponentValue;
00148 
00149 };
00150 
00151 } // end namespace functor
00152 
00153 } // end namespace itk
00154 
00155 #endif
00156 

Generated at Tue Sep 15 02:34:48 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000