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

itkVectorRescaleIntensityImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkVectorRescaleIntensityImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-04-01 14:36:37 $
00007   Version:   $Revision: 1.8 $
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 __itkVectorRescaleIntensityImageFilter_h
00018 #define __itkVectorRescaleIntensityImageFilter_h
00019 
00020 #include "itkUnaryFunctorImageFilter.h"
00021 
00022 namespace itk
00023 {
00024 
00025 // This functor class applies a scaling transformation A.x 
00026 // to input values.
00027 namespace Functor {  
00028  
00029 template< typename TInput, typename  TOutput>
00030 class VectorMagnitudeLinearTransform
00031 {
00032 public:
00033   typedef typename NumericTraits< typename TInput::ValueType >::RealType RealType;
00034   VectorMagnitudeLinearTransform() {}
00035   ~VectorMagnitudeLinearTransform() {}
00036   void SetFactor( RealType a ) { m_Factor = a; }
00037   itkStaticConstMacro(VectorDimension,unsigned int,TInput::Dimension);
00038   bool operator!=( const VectorMagnitudeLinearTransform & other ) const
00039     {
00040     if( m_Factor != other.m_Factor )
00041       {
00042       return true;
00043       }
00044     return false;
00045     }
00046   bool operator==( const VectorMagnitudeLinearTransform & other ) const
00047     {
00048     return !(*this != other);
00049     }
00050   inline TOutput operator()( const TInput & x ) const
00051     {
00052     TOutput  result;
00053     for(unsigned int i=0; i<VectorDimension; i++)
00054       {
00055       const RealType scaledComponent = static_cast<RealType>( x[i] ) * m_Factor;
00056       result[i]= static_cast< typename TOutput::ValueType >( scaledComponent );
00057       }
00058     return result;
00059     }
00060 private:
00061   RealType m_Factor;
00062 }; 
00063 
00064 }  // end namespace functor
00065 
00066 
00084 template <typename  TInputImage, typename  TOutputImage=TInputImage>
00085 class ITK_EXPORT VectorRescaleIntensityImageFilter :
00086     public
00087 UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00088                         Functor::VectorMagnitudeLinearTransform< 
00089   typename TInputImage::PixelType, 
00090   typename TOutputImage::PixelType>   >
00091 {
00092 public:
00094   typedef VectorRescaleIntensityImageFilter  Self;
00095   typedef UnaryFunctorImageFilter<
00096     TInputImage,TOutputImage, 
00097     Functor::VectorMagnitudeLinearTransform< 
00098       typename TInputImage::PixelType, 
00099       typename TOutputImage::PixelType> >    Superclass;
00100   typedef SmartPointer<Self>                 Pointer;
00101   typedef SmartPointer<const Self>           ConstPointer;
00102 
00103   typedef typename TOutputImage::PixelType                  OutputPixelType;
00104   typedef typename TInputImage::PixelType                   InputPixelType;
00105   typedef typename InputPixelType::ValueType                InputValueType;
00106   typedef typename OutputPixelType::ValueType               OutputValueType;
00107   typedef typename NumericTraits<InputValueType>::RealType  InputRealType;
00108   typedef typename NumericTraits<OutputValueType>::RealType OutputRealType;
00109 
00110   typedef typename Superclass::InputImageType      InputImageType;
00111   typedef typename Superclass::InputImagePointer   InputImagePointer;
00112 
00114   itkTypeMacro( VectorRescaleIntensityImageFilter, UnaryFunctorImageFilter );
00115 
00117   itkNewMacro(Self);
00118 
00119   itkSetMacro( OutputMaximumMagnitude, OutputRealType );
00120   itkGetConstReferenceMacro( OutputMaximumMagnitude, OutputRealType );
00121 
00125   itkGetConstReferenceMacro( Scale, InputRealType );
00126   itkGetConstReferenceMacro( Shift, InputRealType );
00128 
00131   itkGetConstReferenceMacro( InputMaximumMagnitude, InputRealType );
00132 
00134   void BeforeThreadedGenerateData(void);
00135 
00137   void PrintSelf(std::ostream& os, Indent indent) const;
00138 
00139 #ifdef ITK_USE_CONCEPT_CHECKING
00140 
00141   itkConceptMacro(InputHasNumericTraitsCheck,
00142                   (Concept::HasNumericTraits<InputValueType>));
00143   itkConceptMacro(OutputHasNumericTraitsCheck,
00144                   (Concept::HasNumericTraits<OutputValueType>));
00145 
00147 #endif
00148 
00149 protected:
00150   VectorRescaleIntensityImageFilter();
00151   virtual ~VectorRescaleIntensityImageFilter() {};
00152 
00153 private:
00154   VectorRescaleIntensityImageFilter(const Self&); //purposely not implemented
00155   void operator=(const Self&); //purposely not implemented
00156 
00157   InputRealType m_Scale;
00158   InputRealType m_Shift;
00159 
00160   InputRealType        m_InputMaximumMagnitude;
00161   OutputRealType       m_OutputMaximumMagnitude;
00162 
00163 };
00164 
00165 
00166   
00167 } // end namespace itk
00168   
00169 #ifndef ITK_MANUAL_INSTANTIATION
00170 #include "itkVectorRescaleIntensityImageFilter.txx"
00171 #endif
00172   
00173 #endif
00174 

Generated at Fri Apr 16 19:58:39 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000