00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkNarrowBandLevelSetImageFilter_h_
00018 #define __itkNarrowBandLevelSetImageFilter_h_
00019
00020 #include "itkNarrowBandImageFilterBase.h"
00021 #include "itkSegmentationLevelSetFunction.h"
00022 #include "itkFastChamferDistanceImageFilter.h"
00023 #include "itkIsoContourDistanceImageFilter.h"
00024
00025 namespace itk {
00026
00139 template <class TInputImage,
00140 class TFeatureImage,
00141 class TOutputPixelType = float,
00142 class TOutputImage = Image<TOutputPixelType,
00143 ::itk::GetImageDimension<TInputImage>::ImageDimension> >
00144 class ITK_EXPORT NarrowBandLevelSetImageFilter
00145 : public NarrowBandImageFilterBase<TInputImage, TOutputImage>
00146 {
00147 public:
00149 typedef NarrowBandLevelSetImageFilter Self;
00150 typedef NarrowBandImageFilterBase<TInputImage, TOutputImage> Superclass;
00151 typedef SmartPointer<Self> Pointer;
00152 typedef SmartPointer<const Self> ConstPointer;
00153
00155 typedef typename Superclass::ValueType ValueType;
00156 typedef typename Superclass::IndexType IndexType;
00157 typedef typename Superclass::TimeStepType TimeStepType;
00158 typedef typename Superclass::InputImageType InputImageType;
00159
00161 typedef TOutputImage OutputImageType;
00162 typedef TFeatureImage FeatureImageType;
00163
00165 typedef SegmentationLevelSetFunction <OutputImageType, FeatureImageType>
00166 SegmentationFunctionType;
00167
00169 typedef typename SegmentationFunctionType::VectorImageType VectorImageType;
00170
00172 itkTypeMacro(NarrowBandLevelSetImageFilter, NarrowBandImageFilterBase);
00173
00176 virtual void SetFeatureImage(const FeatureImageType *f)
00177 {
00178 this->ProcessObject::SetNthInput( 1, const_cast< FeatureImageType * >(f) );
00179 m_SegmentationFunction->SetFeatureImage(f);
00180 }
00181 virtual FeatureImageType * GetFeatureImage()
00182 {
00183 return ( static_cast< FeatureImageType *>(this->ProcessObject::GetInput(1)) );
00184 }
00185
00188 virtual void SetInitialImage(InputImageType *f)
00189 {
00190 this->SetInput(f);
00191 }
00192
00193 virtual const typename SegmentationFunctionType::ImageType *GetSpeedImage() const
00194 { return m_SegmentationFunction->GetSpeedImage(); }
00195
00196 virtual const typename SegmentationFunctionType::VectorImageType *GetAdvectionImage() const
00197 { return m_SegmentationFunction->GetAdvectionImage(); }
00198
00202 void SetUseNegativeFeaturesOn()
00203 {
00204 itkWarningMacro( << "SetUseNegativeFeaturesOn has been deprecated. Please use ReverseExpansionDirectionOn() instead" );
00205 this->ReverseExpansionDirectionOn();
00206 }
00207 void SetUseNegativeFeaturesOff()
00208 {
00209 itkWarningMacro( << "SetUseNegativeFeaturesOff has been deprecated. Please use ReverseExpansionDirectionOff() instead" );
00210 this->ReverseExpansionDirectionOff();
00211 }
00212
00215 void SetUseNegativeFeatures( bool u )
00216 {
00217 itkWarningMacro( << "SetUseNegativeFeatures has been deprecated. Please use SetReverseExpansionDirection instead" );
00218 if (u == true)
00219 {
00220 this->SetReverseExpansionDirection(false);
00221 }
00222 else
00223 {
00224 this->SetReverseExpansionDirection(true);
00225 }
00226 }
00227 bool GetUseNegativeFeatures() const
00228 {
00229 itkWarningMacro( << "GetUseNegativeFeatures has been deprecated. Please use GetReverseExpansionDirection() instead" );
00230 if ( this->GetReverseExpansionDirection() == false)
00231 {
00232 return true;
00233 }
00234 else
00235 {
00236 return false;
00237 }
00238 }
00239
00248 itkSetMacro(ReverseExpansionDirection, bool);
00249 itkGetConstMacro(ReverseExpansionDirection, bool);
00250 itkBooleanMacro(ReverseExpansionDirection);
00251
00256 void SetFeatureScaling(ValueType v)
00257 {
00258 if (v != m_SegmentationFunction->GetPropagationWeight())
00259 {
00260 this->SetPropagationScaling(v);
00261 }
00262 if (v != m_SegmentationFunction->GetAdvectionWeight())
00263 {
00264 this->SetAdvectionScaling(v);
00265 }
00266 }
00267
00270 void SetPropagationScaling(ValueType v)
00271 {
00272 if (v != m_SegmentationFunction->GetPropagationWeight())
00273 {
00274 m_SegmentationFunction->SetPropagationWeight(v);
00275 }
00276 }
00277 ValueType GetPropagationScaling() const
00278 {
00279 return m_SegmentationFunction->GetPropagationWeight();
00280 }
00281
00284 void SetAdvectionScaling(ValueType v)
00285 {
00286 if (v != m_SegmentationFunction->GetAdvectionWeight())
00287 {
00288 m_SegmentationFunction->SetAdvectionWeight(v);
00289 }
00290 }
00291 ValueType GetAdvectionScaling() const
00292 {
00293 return m_SegmentationFunction->GetAdvectionWeight();
00294 }
00295
00299 void SetCurvatureScaling(ValueType v)
00300 {
00301 if (v != m_SegmentationFunction->GetCurvatureWeight())
00302 {
00303 m_SegmentationFunction->SetCurvatureWeight(v);
00304 }
00305 }
00306 ValueType GetCurvatureScaling() const
00307 {
00308 return m_SegmentationFunction->GetCurvatureWeight();
00309 }
00310
00313 virtual void SetSegmentationFunction(SegmentationFunctionType *s);
00314 virtual SegmentationFunctionType *GetSegmentationFunction()
00315 { return m_SegmentationFunction; }
00316
00319 void SetMaximumIterations (unsigned int i)
00320 {
00321 itkWarningMacro("SetMaximumIterations is deprecated. Please use SetNumberOfIterations instead.");
00322 this->SetNumberOfIterations(i);
00323 }
00324 unsigned int GetMaximumIterations()
00325 {
00326 itkWarningMacro("GetMaximumIterations is deprecated. Please use GetNumberOfIterations instead.");
00327 return this->GetNumberOfIterations();
00328 }
00329
00330 virtual void SetMaximumRMSError(const double)
00331 {
00332 itkWarningMacro("The current implmentation of this solver does not compute maximum RMS change. The maximum RMS error value will not be set or used.");
00333 }
00334
00335 protected:
00336 virtual ~NarrowBandLevelSetImageFilter() {}
00337 NarrowBandLevelSetImageFilter();
00338 NarrowBandLevelSetImageFilter(const Self &);
00339
00340 virtual void PrintSelf(std::ostream& os, Indent indent) const;
00341 void operator=(const Self&);
00342
00344 virtual void InitializeIteration()
00345 {
00346 Superclass::InitializeIteration();
00347
00348 this->SetProgress( (float) ((float)this->GetElapsedIterations()
00349 / (float)this->GetNumberOfIterations()) );
00350 }
00351
00355 virtual void CreateNarrowBand ();
00356
00359 void GenerateData();
00360
00363 bool m_ReverseExpansionDirection;
00364
00367 typedef IsoContourDistanceImageFilter<OutputImageType,OutputImageType>
00368 IsoFilterType;
00369 typedef FastChamferDistanceImageFilter<OutputImageType,OutputImageType>
00370 ChamferFilterType;
00371
00372 typename IsoFilterType::Pointer m_IsoFilter;
00373 typename ChamferFilterType::Pointer m_ChamferFilter;
00374
00375 private:
00376 SegmentationFunctionType *m_SegmentationFunction;
00377 };
00378
00379 }
00380
00381 #ifndef ITK_MANUAL_INSTANTIATION
00382 #include "itkNarrowBandLevelSetImageFilter.txx"
00383 #endif
00384
00385 #endif
00386