ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkReinitializeLevelSetImageFilter.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 __itkReinitializeLevelSetImageFilter_h
00019 #define __itkReinitializeLevelSetImageFilter_h
00020 
00021 #include "itkLevelSetNeighborhoodExtractor.h"
00022 #include "itkFastMarchingImageFilter.h"
00023 
00024 namespace itk
00025 {
00054 template< class TLevelSet >
00055 class ITK_EXPORT ReinitializeLevelSetImageFilter:
00056   public ImageToImageFilter< TLevelSet, TLevelSet >
00057 {
00058 public:
00060   typedef ReinitializeLevelSetImageFilter            Self;
00061   typedef ImageToImageFilter< TLevelSet, TLevelSet > Superclass;
00062   typedef SmartPointer< Self >                       Pointer;
00063   typedef SmartPointer< const Self >                 ConstPointer;
00064 
00066   itkNewMacro(Self);
00067 
00069   itkTypeMacro(ReinitializeLevelSetImageFilter, ImageToImageFilter);
00070 
00072   typedef LevelSetTypeDefault< TLevelSet >            LevelSetType;
00073   typedef typename LevelSetType::LevelSetImageType    LevelSetImageType;
00074   typedef typename LevelSetType::LevelSetPointer      LevelSetPointer;
00075   typedef typename LevelSetType::LevelSetConstPointer LevelSetConstPointer;
00076   typedef typename LevelSetType::PixelType            PixelType;
00077   typedef typename LevelSetType::NodeType             NodeType;
00078   typedef typename LevelSetType::NodeContainer        NodeContainer;
00079   typedef typename LevelSetType::NodeContainerPointer NodeContainerPointer;
00080 
00082   itkStaticConstMacro(SetDimension, unsigned int,
00083                       LevelSetType::SetDimension);
00084 
00087   itkSetMacro(LevelSetValue, double);
00088   itkGetConstMacro(LevelSetValue, double);
00090 
00093   itkSetMacro(NarrowBanding, bool);
00094   itkGetConstMacro(NarrowBanding, bool);
00095   itkBooleanMacro(NarrowBanding);
00097 
00099   itkSetClampMacro( InputNarrowBandwidth, double, 0.0,
00100                     NumericTraits< double >::max() );
00101   itkGetConstMacro(InputNarrowBandwidth, double);
00103 
00105   itkSetClampMacro( OutputNarrowBandwidth, double, 0.0,
00106                     NumericTraits< double >::max() );
00107   itkGetConstMacro(OutputNarrowBandwidth, double);
00109 
00112   void SetNarrowBandwidth(double value)
00113   {
00114     this->SetInputNarrowBandwidth(value);
00115     this->SetOutputNarrowBandwidth(value);
00116   }
00118 
00120   void SetInputNarrowBand(NodeContainer *ptr);
00121 
00122   NodeContainerPointer GetInputNarrowBand() const
00123   { return m_InputNarrowBand; }
00124 
00126   NodeContainerPointer GetOutputNarrowBand() const
00127   { return m_OutputNarrowBand; }
00128 
00129 #ifdef ITK_USE_CONCEPT_CHECKING
00130 
00131   itkConceptMacro( LevelSetDoubleAdditiveOperatorsCheck,
00132                    ( Concept::AdditiveOperators< PixelType, double > ) );
00133   itkConceptMacro( LevelSetOStreamWritableCheck,
00134                    ( Concept::OStreamWritable< PixelType > ) );
00135 
00137 #endif
00138 protected:
00139   ReinitializeLevelSetImageFilter();
00140   ~ReinitializeLevelSetImageFilter(){}
00141   void PrintSelf(std::ostream & os, Indent indent) const;
00143 
00145   typedef Image< float, itkGetStaticConstMacro(SetDimension) > SpeedImageType;
00146   typedef LevelSetNeighborhoodExtractor< TLevelSet >           LocatorType;
00147   typedef FastMarchingImageFilter< TLevelSet, SpeedImageType > FastMarchingImageFilterType;
00148 
00149   void GenerateData();
00150 
00151   virtual void GenerateDataFull();
00152 
00153   virtual void GenerateDataNarrowBand();
00154 
00155   virtual void AllocateOutput();
00156 
00157   virtual void GenerateInputRequestedRegion();
00158 
00159   virtual void EnlargeOutputRequestedRegion(DataObject *);
00160 
00161   void SetOutputNarrowBand(NodeContainer *ptr)
00162   { m_OutputNarrowBand = ptr; }
00163 private:
00164   ReinitializeLevelSetImageFilter(const Self &); //purposely not implemented
00165   void operator=(const Self &);                  //purposely not implemented
00166 
00167   double m_LevelSetValue;
00168 
00169   typename LocatorType::Pointer m_Locator;
00170 
00171   typename FastMarchingImageFilterType::Pointer m_Marcher;
00172 
00173   bool                 m_NarrowBanding;
00174   double               m_InputNarrowBandwidth;
00175   double               m_OutputNarrowBandwidth;
00176   NodeContainerPointer m_InputNarrowBand;
00177   NodeContainerPointer m_OutputNarrowBand;
00178 };
00179 } // namespace itk
00180 
00181 #ifndef ITK_MANUAL_INSTANTIATION
00182 #include "itkReinitializeLevelSetImageFilter.hxx"
00183 #endif
00184 
00185 #endif
00186