ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkUpdateMalcolmSparseLevelSet.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 
00019 #ifndef __itkUpdateMalcolmSparseLevelSet_h
00020 #define __itkUpdateMalcolmSparseLevelSet_h
00021 
00022 #include "itkImage.h"
00023 #include "itkDiscreteLevelSetImageBase.h"
00024 #include "itkMalcolmSparseLevelSetImage.h"
00025 #include "itkImageRegionIteratorWithIndex.h"
00026 #include "itkShapedNeighborhoodIterator.h"
00027 #include "itkNeighborhoodAlgorithm.h"
00028 #include "itkLabelMapToLabelImageFilter.h"
00029 #include "itkLabelImageToLabelMapFilter.h"
00030 
00031 namespace itk
00032 {
00041 template< unsigned int VDimension,
00042           class TEquationContainer >
00043 class UpdateMalcolmSparseLevelSet : public Object
00044 {
00045 public:
00046   typedef UpdateMalcolmSparseLevelSet   Self;
00047   typedef SmartPointer< Self >          Pointer;
00048   typedef SmartPointer< const Self >    ConstPointer;
00049   typedef Object                        Superclass;
00050 
00052   itkNewMacro( Self );
00053 
00055   itkTypeMacro( UpdateMalcolmSparseLevelSet, Object );
00056 
00057   itkStaticConstMacro( ImageDimension, unsigned int, VDimension );
00058 
00059   typedef MalcolmSparseLevelSetImage< ImageDimension > LevelSetType;
00060   typedef typename LevelSetType::Pointer               LevelSetPointer;
00061   typedef typename LevelSetType::InputType             LevelSetInputType;
00062   typedef typename LevelSetType::OutputType            LevelSetOutputType;
00063 
00064   typedef typename LevelSetType::LabelMapType          LevelSetLabelMapType;
00065   typedef typename LevelSetType::LabelMapPointer       LevelSetLabelMapPointer;
00066 
00067   typedef typename LevelSetType::LabelObjectType       LevelSetLabelObjectType;
00068   typedef typename LevelSetType::LabelObjectPointer    LevelSetLabelObjectPointer;
00069   typedef typename LevelSetType::LabelObjectLengthType LevelSetLabelObjectLengthType;
00070   typedef typename LevelSetType::LabelObjectLineType   LevelSetLabelObjectLineType;
00071 
00072   typedef typename LevelSetType::LayerType             LevelSetLayerType;
00073   typedef typename LevelSetType::LayerIterator         LevelSetLayerIterator;
00074   typedef typename LevelSetType::LayerConstIterator    LevelSetLayerConstIterator;
00075   typedef typename LevelSetType::OutputRealType        LevelSetOutputRealType;
00076 
00077   typedef typename LevelSetType::LayerMapType           LevelSetLayerMapType;
00078   typedef typename LevelSetType::LayerMapIterator       LevelSetLayerMapIterator;
00079   typedef typename LevelSetType::LayerMapConstIterator  LevelSetLayerMapConstIterator;
00080 
00081   typedef TEquationContainer                                    EquationContainerType;
00082   typedef typename EquationContainerType::Pointer               EquationContainerPointer;
00083   typedef typename EquationContainerType::TermContainerPointer  TermContainerPointer;
00084 
00085   itkGetObjectMacro( OutputLevelSet, LevelSetType );
00086 
00088   void Update();
00089 
00091   itkSetObjectMacro( InputLevelSet, LevelSetType );
00092   itkGetObjectMacro( InputLevelSet, LevelSetType );
00094 
00096   itkGetMacro( RMSChangeAccumulator, LevelSetOutputRealType );
00097 
00099   itkSetObjectMacro( EquationContainer, EquationContainerType );
00100   itkGetObjectMacro( EquationContainer, EquationContainerType );
00102 
00104   itkSetMacro( CurrentLevelSetId, IdentifierType );
00105   itkGetMacro( CurrentLevelSetId, IdentifierType );
00107 
00108 protected:
00109   UpdateMalcolmSparseLevelSet();
00110   virtual ~UpdateMalcolmSparseLevelSet();
00111 
00112   // output
00113   LevelSetPointer   m_OutputLevelSet;
00114 
00115   LevelSetLayerType m_Update;
00116 
00117   IdentifierType           m_CurrentLevelSetId;
00118   LevelSetOutputRealType   m_RMSChangeAccumulator;
00119   EquationContainerPointer m_EquationContainer;
00120 
00121   typedef Image< int8_t, ImageDimension >   LabelImageType;
00122   typedef typename LabelImageType::Pointer  LabelImagePointer;
00123 
00124   LabelImagePointer m_InternalImage;
00125 
00126   typedef ShapedNeighborhoodIterator< LabelImageType > NeighborhoodIteratorType;
00127 
00128   bool m_IsUsingUnPhasedPropagation;
00129 
00131   void FillUpdateContainer();
00132 
00135   void EvolveWithUnPhasedPropagation();
00136 
00139   void EvolveWithPhasedPropagation( LevelSetLayerType& ioList,
00140                                     LevelSetLayerType& ioUpdate,
00141                                     const bool& iContraction );
00142 
00145   void CompactLayersToSinglePixelThickness();
00146 
00147 private:
00148   UpdateMalcolmSparseLevelSet( const Self& ); // purposely not implemented
00149   void operator = ( const Self& );            // purposely not implemented
00150 
00151   // input
00152   LevelSetPointer   m_InputLevelSet;
00153 
00154   typedef std::pair< LevelSetInputType, LevelSetOutputType > NodePairType;
00155 
00156 };
00157 }
00158 
00159 #ifndef ITK_MANUAL_INSTANTIATION
00160 #include "itkUpdateMalcolmSparseLevelSet.hxx"
00161 #endif
00162 
00163 #endif // __itkUpdateMalcolmSparseLevelSet_h
00164