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:
00148
00150 typedef NarrowBandLevelSetImageFilter Self;
00151 typedef NarrowBandImageFilterBase<TInputImage, TOutputImage> Superclass;
00152 typedef SmartPointer<Self> Pointer;
00153 typedef SmartPointer<const Self> ConstPointer;
00154
00156 typedef typename Superclass::ValueType ValueType;
00157 typedef typename Superclass::IndexType IndexType;
00158 typedef typename Superclass::TimeStepType TimeStepType;
00159 typedef typename Superclass::InputImageType InputImageType;
00160
00162 typedef TOutputImage OutputImageType;
00163 typedef TFeatureImage FeatureImageType;
00164
00166 typedef SegmentationLevelSetFunction <OutputImageType, FeatureImageType>
00167 SegmentationFunctionType;
00168
00170 typedef typename SegmentationFunctionType::VectorImageType VectorImageType;
00171
00173 itkTypeMacro(NarrowBandLevelSetImageFilter, NarrowBandImageFilterBase);
00174
00177 virtual void SetFeatureImage(const FeatureImageType *f)
00178 {
00179 this->ProcessObject::SetNthInput( 1, const_cast< FeatureImageType * >(f) );
00180 m_SegmentationFunction->SetFeatureImage(f);
00181 }
00182 virtual FeatureImageType * GetFeatureImage()
00183 {
00184 return ( static_cast< FeatureImageType *>(this->ProcessObject::GetInput(1)) );
00185 }
00187
00190 virtual void SetInitialImage(InputImageType *f)
00191 {
00192 this->SetInput(f);
00193 }
00194
00195 virtual const typename SegmentationFunctionType::ImageType *GetSpeedImage() const
00196 { return m_SegmentationFunction->GetSpeedImage(); }
00197
00198 virtual const typename SegmentationFunctionType::VectorImageType *GetAdvectionImage() const
00199 { return m_SegmentationFunction->GetAdvectionImage(); }
00200
00204 void SetUseNegativeFeaturesOn()
00205 {
00206 itkWarningMacro( << "SetUseNegativeFeaturesOn has been deprecated. Please use ReverseExpansionDirectionOn() instead" );
00207 this->ReverseExpansionDirectionOn();
00208 }
00209 void SetUseNegativeFeaturesOff()
00210 {
00211 itkWarningMacro( << "SetUseNegativeFeaturesOff has been deprecated. Please use ReverseExpansionDirectionOff() instead" );
00212 this->ReverseExpansionDirectionOff();
00213 }
00215
00218 void SetUseNegativeFeatures( bool u )
00219 {
00220 itkWarningMacro( << "SetUseNegativeFeatures has been deprecated. Please use SetReverseExpansionDirection instead" );
00221 if (u == true)
00222 {
00223 this->SetReverseExpansionDirection(false);
00224 }
00225 else
00226 {
00227 this->SetReverseExpansionDirection(true);
00228 }
00229 }
00230 bool GetUseNegativeFeatures() const
00231 {
00232 itkWarningMacro( << "GetUseNegativeFeatures has been deprecated. Please use GetReverseExpansionDirection() instead" );
00233 if ( this->GetReverseExpansionDirection() == false)
00234 {
00235 return true;
00236 }
00237 else
00238 {
00239 return false;
00240 }
00241 }
00243
00252 itkSetMacro(ReverseExpansionDirection, bool);
00253 itkGetConstMacro(ReverseExpansionDirection, bool);
00254 itkBooleanMacro(ReverseExpansionDirection);
00256
00261 void SetFeatureScaling(ValueType v)
00262 {
00263 if (v != m_SegmentationFunction->GetPropagationWeight())
00264 {
00265 this->SetPropagationScaling(v);
00266 }
00267 if (v != m_SegmentationFunction->GetAdvectionWeight())
00268 {
00269 this->SetAdvectionScaling(v);
00270 }
00271 }
00273
00276 void SetPropagationScaling(ValueType v)
00277 {
00278 if (v != m_SegmentationFunction->GetPropagationWeight())
00279 {
00280 m_SegmentationFunction->SetPropagationWeight(v);
00281 }
00282 }
00283 ValueType GetPropagationScaling() const
00284 {
00285 return m_SegmentationFunction->GetPropagationWeight();
00286 }
00288
00291 void SetAdvectionScaling(ValueType v)
00292 {
00293 if (v != m_SegmentationFunction->GetAdvectionWeight())
00294 {
00295 m_SegmentationFunction->SetAdvectionWeight(v);
00296 }
00297 }
00298 ValueType GetAdvectionScaling() const
00299 {
00300 return m_SegmentationFunction->GetAdvectionWeight();
00301 }
00303
00307 void SetCurvatureScaling(ValueType v)
00308 {
00309 if (v != m_SegmentationFunction->GetCurvatureWeight())
00310 {
00311 m_SegmentationFunction->SetCurvatureWeight(v);
00312 }
00313 }
00314 ValueType GetCurvatureScaling() const
00315 {
00316 return m_SegmentationFunction->GetCurvatureWeight();
00317 }
00319
00322 virtual void SetSegmentationFunction(SegmentationFunctionType *s);
00323 virtual SegmentationFunctionType *GetSegmentationFunction()
00324 { return m_SegmentationFunction; }
00326
00329 void SetMaximumIterations (unsigned int i)
00330 {
00331 itkWarningMacro("SetMaximumIterations is deprecated. Please use SetNumberOfIterations instead.");
00332 this->SetNumberOfIterations(i);
00333 }
00334 unsigned int GetMaximumIterations()
00335 {
00336 itkWarningMacro("GetMaximumIterations is deprecated. Please use GetNumberOfIterations instead.");
00337 return this->GetNumberOfIterations();
00338 }
00340
00341 virtual void SetMaximumRMSError(const double)
00342 {
00343 itkWarningMacro("The current implmentation of this solver does not compute maximum RMS change. The maximum RMS error value will not be set or used.");
00344 }
00345
00346 #ifdef ITK_USE_CONCEPT_CHECKING
00347
00348 itkConceptMacro(OutputHasNumericTraitsCheck,
00349 (Concept::HasNumericTraits<typename TOutputImage::PixelType>));
00350
00352 #endif
00353
00354 protected:
00355 virtual ~NarrowBandLevelSetImageFilter() {}
00356 NarrowBandLevelSetImageFilter();
00357 NarrowBandLevelSetImageFilter(const Self &);
00358
00359 virtual void PrintSelf(std::ostream& os, Indent indent) const;
00360 void operator=(const Self&);
00361
00363 virtual void InitializeIteration()
00364 {
00365 Superclass::InitializeIteration();
00366
00367 this->SetProgress( (float) ((float)this->GetElapsedIterations()
00368 / (float)this->GetNumberOfIterations()) );
00369 }
00371
00375 virtual void CreateNarrowBand ();
00376
00379 void GenerateData();
00380
00383 bool m_ReverseExpansionDirection;
00384
00388 typedef IsoContourDistanceImageFilter<OutputImageType,OutputImageType>
00389 IsoFilterType;
00390 typedef FastChamferDistanceImageFilter<OutputImageType,OutputImageType>
00391 ChamferFilterType;
00392
00393 typename IsoFilterType::Pointer m_IsoFilter;
00394 typename ChamferFilterType::Pointer m_ChamferFilter;
00395
00396 private:
00397 SegmentationFunctionType *m_SegmentationFunction;
00398 };
00399
00400 }
00401
00402 #ifndef ITK_MANUAL_INSTANTIATION
00403 #include "itkNarrowBandLevelSetImageFilter.txx"
00404 #endif
00405
00406 #endif
00407
00408