Go to the documentation of this file.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 bool operator!=( const IntensityWindowingTransform & other ) const
00038 {
00039 if( m_Factor != other.m_Factor ||
00040 m_Offset != other.m_Offset ||
00041 m_OutputMaximum != other.m_OutputMaximum ||
00042 m_OutputMinimum != other.m_OutputMinimum ||
00043 m_WindowMaximum != other.m_WindowMaximum ||
00044 m_WindowMinimum != other.m_WindowMinimum )
00045 {
00046 return true;
00047 }
00048 return false;
00049 }
00050 bool operator==( const IntensityWindowingTransform & other ) const
00051 {
00052 return !(*this != other);
00053 }
00054
00055 void SetFactor( RealType a ) { m_Factor = a; }
00056 void SetOffset( RealType b ) { m_Offset = b; }
00057 void SetOutputMinimum( TOutput min ) { m_OutputMinimum = min; }
00058 void SetOutputMaximum( TOutput max ) { m_OutputMaximum = max; }
00059 void SetWindowMinimum( TInput min ) { m_WindowMinimum = min; }
00060 void SetWindowMaximum( TInput max ) { m_WindowMaximum = max; }
00061 inline TOutput operator()( const TInput & x ) const
00062 {
00063 if( x < m_WindowMinimum )
00064 {
00065 return m_OutputMinimum;
00066 }
00067 if( x > m_WindowMaximum )
00068 {
00069 return m_OutputMaximum;
00070 }
00071 const RealType value = static_cast<RealType>(x) * m_Factor + m_Offset;
00072 const TOutput result = static_cast<TOutput>( value );
00073 return result;
00074 }
00075 private:
00076 RealType m_Factor;
00077 RealType m_Offset;
00078 TOutput m_OutputMaximum;
00079 TOutput m_OutputMinimum;
00080 TInput m_WindowMaximum;
00081 TInput m_WindowMinimum;
00082 };
00083
00084 }
00085
00086
00107 template <typename TInputImage, typename TOutputImage=TInputImage>
00108 class ITK_EXPORT IntensityWindowingImageFilter :
00109 public
00110 UnaryFunctorImageFilter<TInputImage,TOutputImage,
00111 Functor::IntensityWindowingTransform<
00112 typename TInputImage::PixelType,
00113 typename TOutputImage::PixelType> >
00114 {
00115 public:
00117 typedef IntensityWindowingImageFilter Self;
00118 typedef UnaryFunctorImageFilter<
00119 TInputImage,TOutputImage,
00120 Functor::IntensityWindowingTransform<
00121 typename TInputImage::PixelType,
00122 typename TOutputImage::PixelType> > Superclass;
00123 typedef SmartPointer<Self> Pointer;
00124 typedef SmartPointer<const Self> ConstPointer;
00125
00126 typedef typename TOutputImage::PixelType OutputPixelType;
00127 typedef typename TInputImage::PixelType InputPixelType;
00128 typedef typename NumericTraits<InputPixelType>::RealType RealType;
00129
00131 itkNewMacro(Self);
00132
00134 itkTypeMacro(IntensityWindowingImageFilter,
00135 UnaryFunctorImageFilter);
00136
00139 itkSetMacro( OutputMinimum, OutputPixelType );
00140 itkSetMacro( OutputMaximum, OutputPixelType );
00141 itkGetConstReferenceMacro( OutputMinimum, OutputPixelType );
00142 itkGetConstReferenceMacro( OutputMaximum, OutputPixelType );
00144
00147 itkSetMacro( WindowMinimum, InputPixelType );
00148 itkSetMacro( WindowMaximum, InputPixelType );
00149 itkGetConstReferenceMacro( WindowMinimum, InputPixelType );
00150 itkGetConstReferenceMacro( WindowMaximum, InputPixelType );
00152
00157 void SetWindowLevel(const InputPixelType& window,
00158 const InputPixelType& level);
00159 InputPixelType GetWindow() const;
00160 InputPixelType GetLevel() const;
00162
00166 itkGetConstReferenceMacro( Scale, RealType );
00167 itkGetConstReferenceMacro( Shift, RealType );
00169
00171 void BeforeThreadedGenerateData(void);
00172
00174 void PrintSelf(std::ostream& os, Indent indent) const;
00175
00176 #ifdef ITK_USE_CONCEPT_CHECKING
00177
00178 itkConceptMacro(InputHasNumericTraitsCheck,
00179 (Concept::HasNumericTraits<InputPixelType>));
00180
00182 #endif
00183
00184 protected:
00185 IntensityWindowingImageFilter();
00186 virtual ~IntensityWindowingImageFilter() {};
00187
00188 private:
00189 IntensityWindowingImageFilter(const Self&);
00190 void operator=(const Self&);
00191
00192 RealType m_Scale;
00193 RealType m_Shift;
00194
00195 InputPixelType m_WindowMinimum;
00196 InputPixelType m_WindowMaximum;
00197
00198 OutputPixelType m_OutputMinimum;
00199 OutputPixelType m_OutputMaximum;
00200
00201 };
00202
00203
00204
00205 }
00206
00207 #ifndef ITK_MANUAL_INSTANTIATION
00208 #include "itkIntensityWindowingImageFilter.txx"
00209 #endif
00210
00211 #endif
00212