ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkNarrowBandLevelSetImageFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkNarrowBandLevelSetImageFilter_h
00019 #define __itkNarrowBandLevelSetImageFilter_h
00020 
00021 #include "itkNarrowBandImageFilterBase.h"
00022 #include "itkSegmentationLevelSetFunction.h"
00023 #include "itkFastChamferDistanceImageFilter.h"
00024 #include "itkIsoContourDistanceImageFilter.h"
00025 
00026 namespace itk
00027 {
00142 template< class TInputImage,
00143           class TFeatureImage,
00144           class TOutputPixelType = float,
00145           class TOutputImage = Image< TOutputPixelType,
00146                                       ::itk::GetImageDimension< TInputImage >::ImageDimension > >
00147 class ITK_EXPORT NarrowBandLevelSetImageFilter:
00148   public NarrowBandImageFilterBase< TInputImage, TOutputImage >
00149 {
00150 public:
00151 
00153   typedef NarrowBandLevelSetImageFilter                          Self;
00154   typedef NarrowBandImageFilterBase< TInputImage, TOutputImage > Superclass;
00155   typedef SmartPointer< Self >                                   Pointer;
00156   typedef SmartPointer< const Self >                             ConstPointer;
00157 
00159   typedef typename Superclass::ValueType      ValueType;
00160   typedef typename Superclass::IndexType      IndexType;
00161   typedef typename Superclass::TimeStepType   TimeStepType;
00162   typedef typename Superclass::InputImageType InputImageType;
00163 
00165   typedef TOutputImage  OutputImageType;
00166   typedef TFeatureImage FeatureImageType;
00167 
00169   typedef SegmentationLevelSetFunction< OutputImageType, FeatureImageType >
00170   SegmentationFunctionType;
00171 
00173   typedef typename SegmentationFunctionType::VectorImageType VectorImageType;
00174 
00176   itkTypeMacro(NarrowBandLevelSetImageFilter, NarrowBandImageFilterBase);
00177 
00180   virtual void SetFeatureImage(const FeatureImageType *f)
00181   {
00182     this->ProcessObject::SetNthInput( 1, const_cast< FeatureImageType * >( f ) );
00183     m_SegmentationFunction->SetFeatureImage(f);
00184   }
00186 
00187   virtual FeatureImageType * GetFeatureImage()
00188   {
00189     return ( static_cast< FeatureImageType * >( this->ProcessObject::GetInput(1) ) );
00190   }
00191 
00194   virtual void SetInitialImage(InputImageType *f)
00195   {
00196     this->SetInput(f);
00197   }
00198 
00199   virtual const typename SegmentationFunctionType::ImageType * GetSpeedImage() const
00200   { return m_SegmentationFunction->GetSpeedImage(); }
00201 
00202   virtual const typename SegmentationFunctionType::VectorImageType * GetAdvectionImage() const
00203   { return m_SegmentationFunction->GetAdvectionImage(); }
00204 
00208   void SetUseNegativeFeaturesOn()
00209   {
00210     itkWarningMacro(
00211       << "SetUseNegativeFeaturesOn has been deprecated.  Please use ReverseExpansionDirectionOn() instead");
00212     this->ReverseExpansionDirectionOn();
00213   }
00215 
00216   void SetUseNegativeFeaturesOff()
00217   {
00218     itkWarningMacro(
00219       << "SetUseNegativeFeaturesOff has been deprecated.  Please use ReverseExpansionDirectionOff() instead");
00220     this->ReverseExpansionDirectionOff();
00221   }
00222 
00225   void SetUseNegativeFeatures(bool u)
00226   {
00227     itkWarningMacro(<< "SetUseNegativeFeatures has been deprecated.  Please use SetReverseExpansionDirection instead");
00228     if ( u == true )
00229       {
00230       this->SetReverseExpansionDirection(false);
00231       }
00232     else
00233       {
00234       this->SetReverseExpansionDirection(true);
00235       }
00236   }
00238 
00239   bool GetUseNegativeFeatures() const
00240   {
00241     itkWarningMacro(<< "GetUseNegativeFeatures has been deprecated.  Please use GetReverseExpansionDirection() instead");
00242     if ( this->GetReverseExpansionDirection() == false )
00243       {
00244       return true;
00245       }
00246     else
00247       {
00248       return false;
00249       }
00250   }
00251 
00260   itkSetMacro(ReverseExpansionDirection, bool);
00261   itkGetConstMacro(ReverseExpansionDirection, bool);
00262   itkBooleanMacro(ReverseExpansionDirection);
00264 
00269   void SetFeatureScaling(ValueType v)
00270   {
00271     if ( v != m_SegmentationFunction->GetPropagationWeight() )
00272       {
00273       this->SetPropagationScaling(v);
00274       }
00275     if ( v != m_SegmentationFunction->GetAdvectionWeight() )
00276       {
00277       this->SetAdvectionScaling(v);
00278       }
00279   }
00281 
00284   void SetPropagationScaling(ValueType v)
00285   {
00286     if ( v != m_SegmentationFunction->GetPropagationWeight() )
00287       {
00288       m_SegmentationFunction->SetPropagationWeight(v);
00289       }
00290   }
00292 
00293   ValueType GetPropagationScaling() const
00294   {
00295     return m_SegmentationFunction->GetPropagationWeight();
00296   }
00297 
00300   void SetAdvectionScaling(ValueType v)
00301   {
00302     if ( v != m_SegmentationFunction->GetAdvectionWeight() )
00303       {
00304       m_SegmentationFunction->SetAdvectionWeight(v);
00305       }
00306   }
00308 
00309   ValueType GetAdvectionScaling() const
00310   {
00311     return m_SegmentationFunction->GetAdvectionWeight();
00312   }
00313 
00318   void SetCurvatureScaling(ValueType v)
00319   {
00320     if ( v != m_SegmentationFunction->GetCurvatureWeight() )
00321       {
00322       m_SegmentationFunction->SetCurvatureWeight(v);
00323       }
00324   }
00326 
00327   ValueType GetCurvatureScaling() const
00328   {
00329     return m_SegmentationFunction->GetCurvatureWeight();
00330   }
00331 
00334   virtual void SetSegmentationFunction(SegmentationFunctionType *s);
00335 
00336   virtual SegmentationFunctionType * GetSegmentationFunction()
00337   { return m_SegmentationFunction; }
00338 
00341   void SetMaximumIterations(unsigned int i)
00342   {
00343     itkWarningMacro("SetMaximumIterations is deprecated.  Please use SetNumberOfIterations instead.");
00344     this->SetNumberOfIterations(i);
00345   }
00347 
00348   unsigned int GetMaximumIterations()
00349   {
00350     itkWarningMacro("GetMaximumIterations is deprecated. Please use GetNumberOfIterations instead.");
00351     return this->GetNumberOfIterations();
00352   }
00353 
00354   virtual void SetMaximumRMSError(const double)
00355   {
00356     itkWarningMacro(
00357       "The current implmentation of this solver does not compute maximum RMS change. The maximum RMS error value will not be set or used.");
00358   }
00359 
00360 #ifdef ITK_USE_CONCEPT_CHECKING
00361 
00362   itkConceptMacro( OutputHasNumericTraitsCheck,
00363                    ( Concept::HasNumericTraits< typename TOutputImage::PixelType > ) );
00364 
00366 #endif
00367 protected:
00368   virtual ~NarrowBandLevelSetImageFilter() {}
00369   NarrowBandLevelSetImageFilter();
00370   NarrowBandLevelSetImageFilter(const Self &); //purposely not implemented
00372 
00373   virtual void PrintSelf(std::ostream & os, Indent indent) const;
00374 
00375   void operator=(const Self &); //purposely not implemented
00376 
00378   virtual void InitializeIteration()
00379   {
00380     Superclass::InitializeIteration();
00381     // Estimate the progress of the filter
00382     this->SetProgress( (float)( (float)this->GetElapsedIterations()
00383                                 / (float)this->GetNumberOfIterations() ) );
00384   }
00386 
00390   virtual void CreateNarrowBand();
00391 
00394   void GenerateData();
00395 
00398   bool m_ReverseExpansionDirection;
00399 
00403   typedef IsoContourDistanceImageFilter< OutputImageType, OutputImageType >
00404   IsoFilterType;
00405   typedef FastChamferDistanceImageFilter< OutputImageType, OutputImageType >
00406   ChamferFilterType;
00407 
00408   typename IsoFilterType::Pointer m_IsoFilter;
00409 
00410   typename ChamferFilterType::Pointer m_ChamferFilter;
00411 private:
00412   SegmentationFunctionType *m_SegmentationFunction;
00413 };
00414 } // end namespace itk
00415 
00416 #ifndef ITK_MANUAL_INSTANTIATION
00417 #include "itkNarrowBandLevelSetImageFilter.hxx"
00418 #endif
00419 
00420 #endif
00421