00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
#ifndef __itkIntensityWindowingImageFilter_h
00018
#define __itkIntensityWindowingImageFilter_h
00019
00020
#include "itkUnaryFunctorImageFilter.h"
00021
00022
namespace itk
00023 {
00024
00025
00026
00027
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 }
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
itkGetConstMacro( OutputMinimum,
OutputPixelType );
00119
itkGetConstMacro( OutputMaximum,
OutputPixelType );
00120
00123
itkSetMacro( WindowMinimum,
InputPixelType );
00124
itkSetMacro( WindowMaximum,
InputPixelType );
00125
itkGetConstMacro( WindowMinimum,
InputPixelType );
00126
itkGetConstMacro( WindowMaximum,
InputPixelType );
00127
00131
itkGetConstMacro( Scale,
RealType );
00132
itkGetConstMacro( Shift,
RealType );
00133
00135
void BeforeThreadedGenerateData(
void);
00136
00138
void PrintSelf(std::ostream& os,
Indent indent)
const;
00139
00140
protected:
00141 IntensityWindowingImageFilter();
00142
virtual ~IntensityWindowingImageFilter() {};
00143
00144
private:
00145 IntensityWindowingImageFilter(
const Self&);
00146
void operator=(
const Self&);
00147
00148
RealType m_Scale;
00149
RealType m_Shift;
00150
00151
InputPixelType m_WindowMinimum;
00152
InputPixelType m_WindowMaximum;
00153
00154
OutputPixelType m_OutputMinimum;
00155
OutputPixelType m_OutputMaximum;
00156
00157 };
00158
00159
00160
00161 }
00162
00163
#ifndef ITK_MANUAL_INSTANTIATION
00164
#include "itkIntensityWindowingImageFilter.txx"
00165
#endif
00166
00167
#endif