ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkUpdateShiSparseLevelSet.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 __itkUpdateShiSparseLevelSet_h
00020 #define __itkUpdateShiSparseLevelSet_h
00021 
00022 #include "itkImage.h"
00023 #include "itkDiscreteLevelSetImageBase.h"
00024 #include "itkShiSparseLevelSetImage.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 UpdateShiSparseLevelSet : public Object
00044 {
00045 public:
00046   typedef UpdateShiSparseLevelSet       Self;
00047   typedef SmartPointer< Self >          Pointer;
00048   typedef SmartPointer< const Self >    ConstPointer;
00049   typedef Object                        Superclass;
00050 
00052   itkNewMacro( Self );
00053 
00055   itkTypeMacro( UpdateShiSparseLevelSet, Object );
00056 
00057   itkStaticConstMacro( ImageDimension, unsigned int, VDimension );
00058 
00059   typedef ShiSparseLevelSetImage< 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   UpdateShiSparseLevelSet();
00110   virtual ~UpdateShiSparseLevelSet();
00111 
00112   // output
00113   LevelSetPointer   m_OutputLevelSet;
00114 
00115   IdentifierType           m_CurrentLevelSetId;
00116   LevelSetOutputRealType   m_RMSChangeAccumulator;
00117   EquationContainerPointer m_EquationContainer;
00118 
00119   typedef Image< int8_t, ImageDimension >   LabelImageType;
00120   typedef typename LabelImageType::Pointer  LabelImagePointer;
00121 
00122   LabelImagePointer m_InternalImage;
00123 
00124   typedef ShapedNeighborhoodIterator< LabelImageType > NeighborhoodIteratorType;
00125 
00127   // this is the same as Procedure 2
00128   // Input is a update image point m_UpdateImage
00129   // Input is also ShiSparseLevelSetImagePointer
00130   void UpdateLayerPlusOne();
00131 
00133   void UpdateLayerMinusOne();
00134 
00136   bool Con( const LevelSetInputType& iIdx,
00137             const LevelSetOutputType& iCurrentStatus,
00138             const LevelSetOutputRealType& iCurrentUpdate ) const;
00139 
00140 private:
00141   UpdateShiSparseLevelSet( const Self& ); // purposely not implemented
00142   void operator = ( const Self& );  // purposely not implemented
00143 
00144   // input
00145   LevelSetPointer   m_InputLevelSet;
00146 
00147   typedef std::pair< LevelSetInputType, LevelSetOutputType > NodePairType;
00148 };
00149 }
00150 
00151 #ifndef ITK_MANUAL_INSTANTIATION
00152 #include "itkUpdateShiSparseLevelSet.hxx"
00153 #endif
00154 
00155 #endif // __itkUpdateShiSparseLevelSet_h
00156