17 #ifndef __itkN3MRIBiasFieldCorrectionImageFilter_h 18 #define __itkN3MRIBiasFieldCorrectionImageFilter_h 20 #include "itkImageToImageFilter.h" 22 #include "itkBSplineScatteredDataPointSetToImageFilter.h" 23 #include "itkPointSet.h" 24 #include "itkSingleValuedCostFunction.h" 25 #include "itkVector.h" 27 #include "vnl/vnl_vector.h" 28 #include "vcl_complex.h" 29 #include "vnl/vnl_complex_traits.h" 91 template<
typename TInputImage,
typename TMaskImage = Image<
unsigned char,
92 TInputImage::ImageDimension>,
typename TOutputImage = TInputImage>
94 public ImageToImageFilter<TInputImage, TOutputImage>
99 typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
100 typedef SmartPointer<Self> Pointer;
101 typedef SmartPointer<const Self> ConstPointer;
111 TInputImage::ImageDimension);
115 typedef TOutputImage OutputImageType;
116 typedef TMaskImage MaskImageType;
117 typedef typename MaskImageType::PixelType MaskPixelType;
119 typedef float RealType;
120 typedef Image<RealType, ImageDimension> RealImageType;
125 itkGetStaticConstMacro(ImageDimension)> PointSetType;
127 itkGetStaticConstMacro(ImageDimension)> ScalarImageType;
128 typedef BSplineScatteredDataPointSetToImageFilter
129 <PointSetType, ScalarImageType> BSplineFilterType;
131 BSplineFilterType::PointDataImageType BiasFieldControlPointLatticeType;
132 typedef typename BSplineFilterType::ArrayType ArrayType;
134 void SetMaskImage(
const MaskImageType *mask)
136 this->SetNthInput(1, const_cast<MaskImageType *>(mask));
138 const MaskImageType* GetMaskImage()
const 140 return static_cast<MaskImageType*>(const_cast<DataObject *>
141 (this->ProcessObject::GetInput(1)));
143 void SetConfidenceImage(
const RealImageType *image)
145 this->SetNthInput(2, const_cast<RealImageType *>(image));
147 const RealImageType* GetConfidenceImage()
const 149 return static_cast<RealImageType*>(const_cast<DataObject *>
150 (this->ProcessObject::GetInput(2)));
153 void SetInput1(
const TInputImage *input)
155 this->SetInput(input);
157 void SetInput2(
const TMaskImage *mask)
159 this->SetMaskImage(mask);
161 void SetInput3(
const RealImageType *image)
163 this->SetConfidenceImage(image);
166 itkSetMacro(MaskLabel, MaskPixelType);
167 itkGetConstMacro(MaskLabel, MaskPixelType);
169 itkSetMacro(NumberOfHistogramBins,
unsigned int);
170 itkGetConstMacro(NumberOfHistogramBins,
unsigned int);
172 itkSetMacro(WeinerFilterNoise, RealType);
173 itkGetConstMacro(WeinerFilterNoise, RealType);
175 itkSetMacro(BiasFieldFullWidthAtHalfMaximum, RealType);
176 itkGetConstMacro(BiasFieldFullWidthAtHalfMaximum, RealType);
178 itkSetMacro(MaximumNumberOfIterations,
unsigned int);
179 itkGetConstMacro(MaximumNumberOfIterations,
unsigned int);
181 itkSetMacro(ConvergenceThreshold, RealType);
182 itkGetConstMacro(ConvergenceThreshold, RealType);
184 itkSetMacro(SplineOrder,
unsigned int);
185 itkGetConstMacro(SplineOrder,
unsigned int);
187 itkSetMacro(NumberOfFittingLevels, ArrayType);
188 itkGetConstMacro(NumberOfFittingLevels, ArrayType);
189 void SetNumberOfFittingLevels(
unsigned int n)
193 this->SetNumberOfFittingLevels(nlevels);
196 itkSetMacro(NumberOfControlPoints, ArrayType);
197 itkGetConstMacro(NumberOfControlPoints, ArrayType);
199 itkGetConstMacro(LogBiasFieldControlPointLattice,
200 typename BiasFieldControlPointLatticeType::Pointer);
202 itkSetMacro(UseOptimalBiasFieldScaling,
bool);
203 itkGetConstMacro(UseOptimalBiasFieldScaling,
bool);
204 itkBooleanMacro(UseOptimalBiasFieldScaling);
206 itkGetConstMacro(BiasFieldScaling, RealType);
208 itkGetConstMacro(ElapsedIterations,
unsigned int);
209 itkGetConstMacro(CurrentConvergenceMeasurement, RealType);
212 N3MRIBiasFieldCorrectionImageFilter();
213 ~N3MRIBiasFieldCorrectionImageFilter() {};
214 void PrintSelf(std::ostream& os, Indent indent)
const;
219 N3MRIBiasFieldCorrectionImageFilter(
const Self&);
220 void operator=(
const Self&);
222 typename RealImageType::Pointer SharpenImage(
223 typename RealImageType::Pointer);
224 typename RealImageType::Pointer SmoothField(
225 typename RealImageType::Pointer);
226 RealType CalculateConvergenceMeasurement(
227 typename RealImageType::Pointer,
228 typename RealImageType::Pointer);
229 RealType CalculateOptimalBiasFieldScaling(
230 typename RealImageType::Pointer);
232 MaskPixelType m_MaskLabel;
237 unsigned int m_NumberOfHistogramBins;
238 RealType m_WeinerFilterNoise;
239 RealType m_BiasFieldFullWidthAtHalfMaximum;
244 unsigned int m_MaximumNumberOfIterations;
245 unsigned int m_ElapsedIterations;
246 RealType m_ConvergenceThreshold;
247 RealType m_CurrentConvergenceMeasurement;
253 BiasFieldControlPointLatticeType::Pointer m_LogBiasFieldControlPointLattice;
254 unsigned int m_SplineOrder;
255 ArrayType m_NumberOfControlPoints;
256 ArrayType m_NumberOfFittingLevels;
261 RealType m_BiasFieldScaling;
262 bool m_UseOptimalBiasFieldScaling;
270 template<
typename TInputImage,
typename TBiasFieldImage,
typename TMaskImage,
typename TConf
idenceImage>
272 :
public SingleValuedCostFunction
276 typedef SingleValuedCostFunction Superclass;
277 typedef SmartPointer<Self> Pointer;
278 typedef SmartPointer<const Self> ConstPointer;
286 typedef Superclass::MeasureType MeasureType;
287 typedef Superclass::DerivativeType DerivativeType;
288 typedef Superclass::ParametersType ParametersType;
290 itkSetObjectMacro( InputImage, TInputImage );
291 itkSetObjectMacro( BiasFieldImage, TBiasFieldImage );
292 itkSetObjectMacro( MaskImage, TMaskImage );
293 itkSetObjectMacro( ConfidenceImage, TConfidenceImage );
295 itkSetMacro( MaskLabel,
typename TMaskImage::PixelType );
296 itkGetConstMacro( MaskLabel,
typename TMaskImage::PixelType );
298 virtual MeasureType GetValue(
const ParametersType & parameters )
const;
299 virtual void GetDerivative(
const ParametersType & parameters,
300 DerivativeType & derivative )
const;
301 virtual unsigned int GetNumberOfParameters()
const;
309 void operator=(
const Self&);
311 typename TInputImage::Pointer m_InputImage;
312 typename TBiasFieldImage::Pointer m_BiasFieldImage;
313 typename TMaskImage::Pointer m_MaskImage;
314 typename TConfidenceImage::Pointer m_ConfidenceImage;
316 typename TMaskImage::PixelType m_MaskLabel;
322 #ifndef ITK_MANUAL_INSTANTIATION 323 #include "itkN3MRIBiasFieldCorrectionImageFilter.cpp" TInputImage InputImageType
Some convenient typedefs.
Definition: itkN3MRIBiasFieldCorrectionImageFilter.h:114
Class definition for N3MRIBiasFieldCorrectionImageFilter.
Definition: itkN3MRIBiasFieldCorrectionImageFilter.h:93
Class definition for N3BiasFieldScaleCostFunction.
Definition: itkN3MRIBiasFieldCorrectionImageFilter.h:271
itkTypeMacro(N3MRIBiasFieldCorrectionImageFilter, ImageToImageFilter)
Runtime information support.
itkNewMacro(Self)
Method for creation through the object factory.
N3MRIBiasFieldCorrectionImageFilter Self
Standard class typedefs.
Definition: itkN3MRIBiasFieldCorrectionImageFilter.h:98
Vector< RealType, 1 > ScalarType
B-spline smoothing filter typedefs.
Definition: itkN3MRIBiasFieldCorrectionImageFilter.h:123
itkNewMacro(Self)
Standard New method.
itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension)
ImageDimension constants.
itkTypeMacro(N3BiasFieldScaleCostFunction, SingleValuedCostFunction)
Run-time type information (and related methods).