00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkVectorRescaleIntensityImageFilter_h
00018 #define __itkVectorRescaleIntensityImageFilter_h
00019
00020 #include "itkUnaryFunctorImageFilter.h"
00021
00022 namespace itk
00023 {
00024
00025
00026
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 )
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 }
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<TInputImage,TOutputImage,
00096 Functor::VectorMagnitudeLinearTransform<
00097 typename TInputImage::PixelType,
00098 typename TOutputImage::PixelType> > Superclass;
00099 typedef SmartPointer<Self> Pointer;
00100 typedef SmartPointer<const Self> ConstPointer;
00101
00102 typedef typename TOutputImage::PixelType OutputPixelType;
00103 typedef typename TInputImage::PixelType InputPixelType;
00104 typedef typename InputPixelType::ValueType InputValueType;
00105 typedef typename OutputPixelType::ValueType OutputValueType;
00106 typedef typename NumericTraits<InputValueType>::RealType InputRealType;
00107 typedef typename NumericTraits<OutputValueType>::RealType OutputRealType;
00108
00109 typedef typename Superclass::InputImageType InputImageType;
00110 typedef typename Superclass::InputImagePointer InputImagePointer;
00111
00113 itkTypeMacro( VectorRescaleIntensityImageFilter, UnaryFunctorImageFilter );
00114
00116 itkNewMacro(Self);
00117
00118 itkSetMacro( OutputMaximumMagnitude, OutputRealType );
00119 itkGetConstReferenceMacro( OutputMaximumMagnitude, OutputRealType );
00120
00124 itkGetConstReferenceMacro( Scale, InputRealType );
00125 itkGetConstReferenceMacro( Shift, InputRealType );
00127
00130 itkGetConstReferenceMacro( InputMaximumMagnitude, InputRealType );
00131
00133 void BeforeThreadedGenerateData(void);
00134
00136 void PrintSelf(std::ostream& os, Indent indent) const;
00137
00138 #ifdef ITK_USE_CONCEPT_CHECKING
00139
00140 itkConceptMacro(InputHasNumericTraitsCheck,
00141 (Concept::HasNumericTraits<InputValueType>));
00142 itkConceptMacro(OutputHasNumericTraitsCheck,
00143 (Concept::HasNumericTraits<OutputValueType>));
00144
00146 #endif
00147
00148 protected:
00149 VectorRescaleIntensityImageFilter();
00150 virtual ~VectorRescaleIntensityImageFilter() {};
00151
00152 private:
00153 VectorRescaleIntensityImageFilter(const Self&);
00154 void operator=(const Self&);
00155
00156 InputRealType m_Scale;
00157 InputRealType m_Shift;
00158
00159 InputRealType m_InputMaximumMagnitude;
00160 OutputRealType m_OutputMaximumMagnitude;
00161
00162 };
00163
00164
00165
00166 }
00167
00168 #ifndef ITK_MANUAL_INSTANTIATION
00169 #include "itkVectorRescaleIntensityImageFilter.txx"
00170 #endif
00171
00172 #endif
00173