itkN4MRIBiasFieldCorrectionImageFilter.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __itkN4MRIBiasFieldCorrectionImageFilter_h
00019 #define __itkN4MRIBiasFieldCorrectionImageFilter_h
00020
00021 #include "itkImageToImageFilter.h"
00022
00023 #include "itkArray.h"
00024 #include "itkBSplineScatteredDataPointSetToImageFilter.h"
00025 #include "itkPointSet.h"
00026 #include "itkVector.h"
00027
00028 #include "vnl/vnl_vector.h"
00029
00030 namespace itk {
00031
00089 template<class TInputImage, class TMaskImage =
00090 Image<unsigned char, ::itk::GetImageDimension<TInputImage>::ImageDimension>,
00091 class TOutputImage = TInputImage>
00092 class ITK_EXPORT N4MRIBiasFieldCorrectionImageFilter :
00093 public ImageToImageFilter<TInputImage, TOutputImage>
00094 {
00095 public:
00097 typedef N4MRIBiasFieldCorrectionImageFilter Self;
00098 typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
00099 typedef SmartPointer<Self> Pointer;
00100 typedef SmartPointer<const Self> ConstPointer;
00101
00103 itkTypeMacro( N4MRIBiasFieldCorrectionImageFilter, ImageToImageFilter );
00104
00106 itkNewMacro( Self );
00107
00109 itkStaticConstMacro( ImageDimension, unsigned int,
00110 TInputImage::ImageDimension );
00111
00113 typedef TInputImage InputImageType;
00114 typedef TOutputImage OutputImageType;
00115 typedef TMaskImage MaskImageType;
00116 typedef typename MaskImageType::PixelType MaskPixelType;
00117
00118 typedef float RealType;
00119 typedef Image<RealType, ImageDimension> RealImageType;
00120 typedef typename RealImageType::Pointer RealImagePointer;
00121 typedef Array<unsigned int> VariableSizeArrayType;
00122
00124 typedef Vector<RealType, 1> ScalarType;
00125 typedef PointSet<ScalarType, itkGetStaticConstMacro( ImageDimension )> PointSetType;
00126 typedef Image<ScalarType, itkGetStaticConstMacro( ImageDimension )> ScalarImageType;
00127 typedef typename PointSetType::Pointer PointSetPointer;
00128 typedef typename PointSetType::PointType PointType;
00129
00131 typedef BSplineScatteredDataPointSetToImageFilter<
00132 PointSetType, ScalarImageType> BSplineFilterType;
00133 typedef typename BSplineFilterType::PointDataImageType BiasFieldControlPointLatticeType;
00134 typedef typename BSplineFilterType::ArrayType ArrayType;
00135
00141 void SetMaskImage( const MaskImageType *mask )
00142 {
00143 this->SetNthInput( 1, const_cast<MaskImageType *>( mask ) );
00144 }
00145
00151 const MaskImageType* GetMaskImage() const
00152 {
00153 return static_cast<const MaskImageType*>( this->ProcessObject::GetInput( 1 ) );
00154 }
00155
00166 void SetConfidenceImage( const RealImageType *image )
00167 {
00168 this->SetNthInput( 2, const_cast<RealImageType *>( image ) );
00169 }
00170
00181 const RealImageType* GetConfidenceImage() const
00182 {
00183 return static_cast<const RealImageType*>( this->ProcessObject::GetInput( 2 ) );
00184 }
00185
00191 itkSetMacro( MaskLabel, MaskPixelType );
00192
00198 itkGetConstMacro( MaskLabel, MaskPixelType );
00199
00200
00201
00202
00203
00204
00209 itkSetMacro( NumberOfHistogramBins, unsigned int );
00210
00215 itkGetConstMacro( NumberOfHistogramBins, unsigned int );
00216
00220 itkSetMacro( WienerFilterNoise, RealType );
00221
00225 itkGetConstMacro( WienerFilterNoise, RealType );
00226
00231 itkSetMacro( BiasFieldFullWidthAtHalfMaximum, RealType );
00232
00237 itkGetConstMacro( BiasFieldFullWidthAtHalfMaximum, RealType );
00238
00239
00240
00244 itkSetMacro( SplineOrder, unsigned int );
00245
00249 itkGetConstMacro( SplineOrder, unsigned int );
00250
00258 itkSetMacro( NumberOfControlPoints, ArrayType );
00259
00267 itkGetConstMacro( NumberOfControlPoints, ArrayType );
00268
00275 itkSetMacro( NumberOfFittingLevels, ArrayType );
00276
00283 void SetNumberOfFittingLevels( unsigned int n )
00284 {
00285 ArrayType nlevels;
00286
00287 nlevels.Fill( n );
00288 this->SetNumberOfFittingLevels( nlevels );
00289 }
00290
00297 itkGetConstMacro( NumberOfFittingLevels, ArrayType );
00298
00303 itkSetMacro( MaximumNumberOfIterations, VariableSizeArrayType );
00304
00309 itkGetConstMacro( MaximumNumberOfIterations, VariableSizeArrayType );
00310
00318 itkSetMacro( ConvergenceThreshold, RealType );
00319
00327 itkGetConstMacro( ConvergenceThreshold, RealType );
00328
00338 itkGetConstMacro( LogBiasFieldControlPointLattice,
00339 typename BiasFieldControlPointLatticeType::Pointer );
00340
00345 itkGetConstMacro( ElapsedIterations, unsigned int );
00346
00351 itkGetConstMacro( CurrentConvergenceMeasurement, RealType );
00352
00357 itkGetConstMacro( CurrentLevel, unsigned int );
00358
00359 protected:
00360 N4MRIBiasFieldCorrectionImageFilter();
00361 ~N4MRIBiasFieldCorrectionImageFilter() {}
00362 void PrintSelf( std::ostream& os, Indent indent ) const;
00363
00364 void GenerateData();
00365
00366 private:
00367 N4MRIBiasFieldCorrectionImageFilter( const Self& );
00368
00369 void operator=( const Self& );
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00385 RealImagePointer SharpenImage( const RealImageType * ) const;
00386
00392 RealImagePointer UpdateBiasFieldEstimate( RealImageType * );
00393
00398 RealType CalculateConvergenceMeasurement( const RealImageType *, const RealImageType * ) const;
00399
00400
00401 MaskPixelType m_MaskLabel;
00402
00403
00404
00405 unsigned int m_NumberOfHistogramBins;
00406 RealType m_WienerFilterNoise;
00407 RealType m_BiasFieldFullWidthAtHalfMaximum;
00408
00409
00410
00411 VariableSizeArrayType m_MaximumNumberOfIterations;
00412 unsigned int m_ElapsedIterations;
00413 RealType m_ConvergenceThreshold;
00414 RealType m_CurrentConvergenceMeasurement;
00415 unsigned int m_CurrentLevel;
00416
00417
00418
00419 typename
00420 BiasFieldControlPointLatticeType::Pointer m_LogBiasFieldControlPointLattice;
00421
00422 unsigned int m_SplineOrder;
00423 ArrayType m_NumberOfControlPoints;
00424 ArrayType m_NumberOfFittingLevels;
00425
00426 };
00427
00428 }
00429
00430 #ifndef ITK_MANUAL_INSTANTIATION
00431 #include "itkN4MRIBiasFieldCorrectionImageFilter.txx"
00432 #endif
00433
00434 #endif