00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
#ifndef __itkRescaleIntensityImageFilter_h
00018
#define __itkRescaleIntensityImageFilter_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 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 }
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
00115
itkSetMacro( InputMaximum,
InputPixelType );
00116
itkSetMacro( InputMinimum,
InputPixelType );
00117
00119
void BeforeThreadedGenerateData(
void);
00120
00122
void PrintSelf(std::ostream& os,
Indent indent)
const;
00123
00124
protected:
00125 RescaleIntensityImageFilter();
00126
virtual ~RescaleIntensityImageFilter() {};
00127
00128
private:
00129 RescaleIntensityImageFilter(
const Self&);
00130
void operator=(
const Self&);
00131
00132
RealType m_Scale;
00133
RealType m_Shift;
00134
00135
InputPixelType m_InputMinimum;
00136
InputPixelType m_InputMaximum;
00137
00138
OutputPixelType m_OutputMinimum;
00139
OutputPixelType m_OutputMaximum;
00140
00141 };
00142
00143
00144
00145 }
00146
00147
#ifndef ITK_MANUAL_INSTANTIATION
00148
#include "itkRescaleIntensityImageFilter.txx"
00149
#endif
00150
00151
#endif