ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
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 00020 #ifndef __itkLevelSetEvolution_h 00021 #define __itkLevelSetEvolution_h 00022 00023 #include "itkLevelSetEvolutionBase.h" 00024 #include "itkLevelSetDenseImageBase.h" 00025 00026 #include "itkWhitakerSparseLevelSetImage.h" 00027 #include "itkUpdateWhitakerSparseLevelSet.h" 00028 00029 #include "itkShiSparseLevelSetImage.h" 00030 #include "itkUpdateShiSparseLevelSet.h" 00031 00032 #include "itkMalcolmSparseLevelSetImage.h" 00033 #include "itkUpdateMalcolmSparseLevelSet.h" 00034 00035 #include "itkLevelSetEvolutionComputeIterationThreader.h" 00036 #include "itkLevelSetEvolutionUpdateLevelSetsThreader.h" 00037 00038 namespace itk 00039 { 00049 template< class TEquationContainer, class TLevelSet > 00050 class LevelSetEvolution 00051 {}; 00052 00053 template< class TEquationContainer, class TImage > 00054 class LevelSetEvolution< TEquationContainer, 00055 LevelSetDenseImageBase< TImage > > : 00056 public LevelSetEvolutionBase< TEquationContainer, LevelSetDenseImageBase< TImage > > 00057 { 00058 public: 00059 typedef LevelSetDenseImageBase< TImage > LevelSetType; 00060 00061 typedef LevelSetEvolution Self; 00062 typedef SmartPointer< Self > Pointer; 00063 typedef SmartPointer< const Self > ConstPointer; 00064 typedef LevelSetEvolutionBase< TEquationContainer, LevelSetType > Superclass; 00065 00067 itkNewMacro( Self ); 00068 00070 itkTypeMacro( LevelSetEvolution, LevelSetEvolutionBase ); 00071 00072 typedef typename Superclass::EquationContainerType EquationContainerType; 00073 typedef typename Superclass::EquationContainerPointer EquationContainerPointer; 00074 typedef typename Superclass::TermContainerType TermContainerType; 00075 typedef typename Superclass::TermContainerPointer TermContainerPointer; 00076 00077 typedef typename Superclass::TermType TermType; 00078 typedef typename Superclass::TermPointer TermPointer; 00079 00080 typedef typename Superclass::InputImageType InputImageType; 00081 typedef typename Superclass::InputImagePixelType InputImagePixelType; 00082 typedef typename Superclass::InputImageConstPointer InputImageConstPointer; 00083 typedef typename Superclass::InputImageRegionType InputImageRegionType; 00084 typedef typename Superclass::InputPixelRealType InputPixelRealType; 00085 00086 itkStaticConstMacro ( ImageDimension, unsigned int, Superclass::ImageDimension ); 00087 00088 typedef typename Superclass::LevelSetContainerType LevelSetContainerType; 00089 00090 typedef typename Superclass::LevelSetIdentifierType LevelSetIdentifierType; 00091 00092 typedef typename LevelSetType::ImageType LevelSetImageType; 00093 00094 typedef typename Superclass::LevelSetOutputType LevelSetOutputType; 00095 typedef typename Superclass::LevelSetOutputRealType LevelSetOutputRealType; 00096 typedef typename Superclass::LevelSetDataType LevelSetDataType; 00097 00098 typedef typename Superclass::IdListType IdListType; 00099 typedef typename Superclass::IdListIterator IdListIterator; 00100 typedef typename Superclass::IdListConstIterator IdListConstIterator; 00101 typedef typename Superclass::IdListImageType IdListImageType; 00102 typedef typename Superclass::CacheImageType CacheImageType; 00103 typedef typename Superclass::DomainMapImageFilterType DomainMapImageFilterType; 00104 00105 typedef typename Superclass::StoppingCriterionType StoppingCriterionType; 00106 typedef typename Superclass::StoppingCriterionPointer StoppingCriterionPointer; 00107 00108 typedef BinaryThresholdImageFilter< LevelSetImageType, LevelSetImageType > ThresholdFilterType; 00109 typedef typename ThresholdFilterType::Pointer ThresholdFilterPointer; 00110 00111 typedef SignedMaurerDistanceMapImageFilter< LevelSetImageType, LevelSetImageType > MaurerType; 00112 typedef typename MaurerType::Pointer MaurerPointer; 00113 00114 typedef ImageRegionIteratorWithIndex< LevelSetImageType > LevelSetImageIteratorType; 00115 00116 typedef ImageRegionConstIteratorWithIndex< LevelSetImageType > LevelSetImageConstIteratorType; 00117 00118 typedef ImageRegionConstIteratorWithIndex< InputImageType > InputImageConstIteratorType; 00119 00120 protected: 00121 LevelSetEvolution(); 00122 ~LevelSetEvolution(); 00123 00126 virtual void AllocateUpdateBuffer(); 00127 00129 virtual void ComputeIteration(); 00130 00132 virtual void ComputeTimeStepForNextIteration(); 00133 00135 virtual void UpdateLevelSets(); 00136 00138 virtual void UpdateEquations(); 00139 00141 void ReinitializeToSignedDistance(); 00142 00143 typename LevelSetContainerType::Pointer m_UpdateBuffer; 00144 00145 friend class LevelSetEvolutionComputeIterationThreader< LevelSetType, ThreadedImageRegionPartitioner< TImage::ImageDimension >, Self >; 00146 typedef LevelSetEvolutionComputeIterationThreader< LevelSetType, ThreadedImageRegionPartitioner< TImage::ImageDimension >, Self > SplitLevelSetComputeIterationThreaderType; 00147 typename SplitLevelSetComputeIterationThreaderType::Pointer m_SplitLevelSetComputeIterationThreader; 00148 00149 typedef typename DomainMapImageFilterType::DomainMapType::const_iterator DomainMapConstIteratorType; 00150 typedef ThreadedIteratorRangePartitioner< DomainMapConstIteratorType > ThreadedDomainMapPartitionerType; 00151 friend class LevelSetEvolutionComputeIterationThreader< LevelSetType, ThreadedDomainMapPartitionerType, Self >; 00152 typedef LevelSetEvolutionComputeIterationThreader< LevelSetType, ThreadedDomainMapPartitionerType, Self > SplitDomainMapComputeIterationThreaderType; 00153 typename SplitDomainMapComputeIterationThreaderType::Pointer m_SplitDomainMapComputeIterationThreader; 00154 00155 friend class LevelSetEvolutionUpdateLevelSetsThreader< LevelSetType, ThreadedImageRegionPartitioner< TImage::ImageDimension >, Self >; 00156 typedef LevelSetEvolutionUpdateLevelSetsThreader< LevelSetType, ThreadedImageRegionPartitioner< TImage::ImageDimension >, Self > SplitLevelSetUpdateLevelSetsThreaderType; 00157 typename SplitLevelSetUpdateLevelSetsThreaderType::Pointer m_SplitLevelSetUpdateLevelSetsThreader; 00158 00160 const IdListType * m_IdListToProcessWhenThreading; 00161 }; 00162 00163 00164 template< class TEquationContainer, typename TOutput, unsigned int VDimension > 00165 class LevelSetEvolution< TEquationContainer, WhitakerSparseLevelSetImage< TOutput, VDimension > > : 00166 public LevelSetEvolutionBase< TEquationContainer, WhitakerSparseLevelSetImage< TOutput, VDimension > > 00167 { 00168 public: 00169 typedef WhitakerSparseLevelSetImage< TOutput, VDimension > LevelSetType; 00170 00171 typedef LevelSetEvolution Self; 00172 typedef SmartPointer< Self > Pointer; 00173 typedef SmartPointer< const Self > ConstPointer; 00174 typedef LevelSetEvolutionBase< TEquationContainer, LevelSetType > Superclass; 00175 00177 itkNewMacro( Self ); 00178 00180 itkTypeMacro( LevelSetEvolution, LevelSetEvolutionBase ); 00181 00182 typedef typename Superclass::EquationContainerType EquationContainerType; 00183 typedef typename Superclass::EquationContainerPointer EquationContainerPointer; 00184 typedef typename Superclass::TermContainerType TermContainerType; 00185 typedef typename Superclass::TermContainerPointer TermContainerPointer; 00186 00187 typedef typename Superclass::TermType TermType; 00188 typedef typename Superclass::TermPointer TermPointer; 00189 00190 typedef typename Superclass::InputImageType InputImageType; 00191 typedef typename Superclass::InputImagePixelType InputImagePixelType; 00192 typedef typename Superclass::InputImageConstPointer InputImageConstPointer; 00193 typedef typename Superclass::InputImageRegionType InputImageRegionType; 00194 typedef typename Superclass::InputPixelRealType InputPixelRealType; 00195 00196 itkStaticConstMacro ( ImageDimension, unsigned int, Superclass::ImageDimension ); 00197 00198 typedef typename Superclass::LevelSetContainerType LevelSetContainerType; 00199 typedef typename Superclass::LevelSetIdentifierType LevelSetIdentifierType; 00200 00201 typedef typename Superclass::LevelSetInputType LevelSetInputType; 00202 typedef typename Superclass::LevelSetOutputType LevelSetOutputType; 00203 typedef typename Superclass::LevelSetOutputRealType LevelSetOutputRealType; 00204 typedef typename Superclass::LevelSetDataType LevelSetDataType; 00205 00206 typedef typename LevelSetType::LayerType LevelSetLayerType; 00207 00208 typedef typename LevelSetType::LabelMapType LevelSetLabelMapType; 00209 typedef typename LevelSetType::LabelMapPointer LevelSetLabelMapPointer; 00210 00211 00212 typedef typename Superclass::IdListType IdListType; 00213 typedef typename Superclass::IdListIterator IdListIterator; 00214 typedef typename Superclass::IdListImageType IdListImageType; 00215 typedef typename Superclass::CacheImageType CacheImageType; 00216 typedef typename Superclass::DomainMapImageFilterType DomainMapImageFilterType; 00217 00218 typedef typename Superclass::StoppingCriterionType StoppingCriterionType; 00219 typedef typename Superclass::StoppingCriterionPointer StoppingCriterionPointer; 00220 00221 typedef ImageRegionConstIteratorWithIndex< InputImageType > InputImageConstIteratorType; 00222 00223 typedef UpdateWhitakerSparseLevelSet< ImageDimension, LevelSetOutputType, EquationContainerType > UpdateLevelSetFilterType; 00224 typedef typename UpdateLevelSetFilterType::Pointer UpdateLevelSetFilterPointer; 00225 00226 protected: 00227 LevelSetEvolution(); 00228 ~LevelSetEvolution(); 00229 00230 typedef std::pair< LevelSetInputType, LevelSetOutputType > NodePairType; 00231 00232 // For sparse case, the update buffer needs to be the size of the active layer 00233 std::map< IdentifierType, LevelSetLayerType* > m_UpdateBuffer; 00234 00237 virtual void AllocateUpdateBuffer(); 00238 00240 virtual void ComputeIteration(); 00241 00243 virtual void ComputeTimeStepForNextIteration(); 00244 00246 virtual void UpdateLevelSets(); 00247 00249 virtual void UpdateEquations(); 00250 00251 typedef ThreadedIteratorRangePartitioner< typename LevelSetType::LayerConstIterator > SplitLevelSetPartitionerType; 00252 friend class LevelSetEvolutionComputeIterationThreader< LevelSetType, SplitLevelSetPartitionerType, Self >; 00253 typedef LevelSetEvolutionComputeIterationThreader< LevelSetType, SplitLevelSetPartitionerType, Self > SplitLevelSetComputeIterationThreaderType; 00254 typename SplitLevelSetComputeIterationThreaderType::Pointer m_SplitLevelSetComputeIterationThreader; 00255 00256 private: 00257 LevelSetEvolution( const Self& ); 00258 void operator = ( const Self& ); 00259 }; 00260 00261 00262 // Shi 00263 template< class TEquationContainer, unsigned int VDimension > 00264 class LevelSetEvolution< 00265 TEquationContainer, 00266 ShiSparseLevelSetImage< VDimension > > : 00267 public LevelSetEvolutionBase< TEquationContainer, ShiSparseLevelSetImage< VDimension > > 00268 { 00269 public: 00270 typedef ShiSparseLevelSetImage< VDimension > LevelSetType; 00271 00272 typedef LevelSetEvolution Self; 00273 typedef SmartPointer< Self > Pointer; 00274 typedef SmartPointer< const Self > ConstPointer; 00275 typedef LevelSetEvolutionBase< TEquationContainer, LevelSetType > Superclass; 00276 00278 itkNewMacro( Self ); 00279 00281 itkTypeMacro( LevelSetEvolution, LevelSetEvolutionBase ); 00282 00283 typedef typename Superclass::EquationContainerType EquationContainerType; 00284 typedef typename Superclass::EquationContainerPointer EquationContainerPointer; 00285 typedef typename Superclass::TermContainerType TermContainerType; 00286 typedef typename Superclass::TermContainerPointer TermContainerPointer; 00287 00288 typedef typename Superclass::TermType TermType; 00289 typedef typename Superclass::TermPointer TermPointer; 00290 00291 typedef typename Superclass::InputImageType InputImageType; 00292 typedef typename Superclass::InputImagePixelType InputImagePixelType; 00293 typedef typename Superclass::InputImageConstPointer InputImageConstPointer; 00294 typedef typename Superclass::InputImageRegionType InputImageRegionType; 00295 typedef typename Superclass::InputPixelRealType InputPixelRealType; 00296 00297 itkStaticConstMacro ( ImageDimension, unsigned int, Superclass::ImageDimension ); 00298 00299 typedef typename Superclass::LevelSetContainerType LevelSetContainerType; 00300 typedef typename Superclass::LevelSetIdentifierType LevelSetIdentifierType; 00301 00302 typedef typename Superclass::LevelSetInputType LevelSetInputType; 00303 typedef typename Superclass::LevelSetOutputType LevelSetOutputType; 00304 typedef typename Superclass::LevelSetOutputRealType LevelSetOutputRealType; 00305 typedef typename Superclass::LevelSetDataType LevelSetDataType; 00306 00307 typedef typename LevelSetType::LayerType LevelSetLayerType; 00308 00309 typedef typename LevelSetType::LabelMapType LevelSetLabelMapType; 00310 typedef typename LevelSetType::LabelMapPointer LevelSetLabelMapPointer; 00311 00312 00313 typedef typename Superclass::IdListType IdListType; 00314 typedef typename Superclass::IdListIterator IdListIterator; 00315 typedef typename Superclass::IdListImageType IdListImageType; 00316 typedef typename Superclass::CacheImageType CacheImageType; 00317 typedef typename Superclass::DomainMapImageFilterType DomainMapImageFilterType; 00318 00319 typedef typename Superclass::StoppingCriterionType StoppingCriterionType; 00320 typedef typename Superclass::StoppingCriterionPointer StoppingCriterionPointer; 00321 00322 typedef ImageRegionConstIteratorWithIndex< InputImageType > InputImageConstIteratorType; 00323 00324 typedef UpdateShiSparseLevelSet< ImageDimension, EquationContainerType > UpdateLevelSetFilterType; 00325 typedef typename UpdateLevelSetFilterType::Pointer UpdateLevelSetFilterPointer; 00326 00327 protected: 00328 LevelSetEvolution(); 00329 ~LevelSetEvolution(); 00330 00332 virtual void UpdateLevelSets(); 00333 00335 virtual void UpdateEquations(); 00336 00337 private: 00338 LevelSetEvolution( const Self& ); 00339 void operator = ( const Self& ); 00340 }; 00341 00342 // Malcolm 00343 template< class TEquationContainer, unsigned int VDimension > 00344 class LevelSetEvolution< TEquationContainer, 00345 MalcolmSparseLevelSetImage< VDimension > > : 00346 public LevelSetEvolutionBase< TEquationContainer, MalcolmSparseLevelSetImage< VDimension > > 00347 { 00348 public: 00349 typedef MalcolmSparseLevelSetImage< VDimension > LevelSetType; 00350 00351 typedef LevelSetEvolution Self; 00352 typedef SmartPointer< Self > Pointer; 00353 typedef SmartPointer< const Self > ConstPointer; 00354 typedef LevelSetEvolutionBase< TEquationContainer, LevelSetType > Superclass; 00355 00357 itkNewMacro( Self ); 00358 00360 itkTypeMacro( LevelSetEvolution, LevelSetEvolutionBase ); 00361 00362 typedef typename Superclass::EquationContainerType EquationContainerType; 00363 typedef typename Superclass::EquationContainerPointer EquationContainerPointer; 00364 typedef typename Superclass::TermContainerType TermContainerType; 00365 typedef typename Superclass::TermContainerPointer TermContainerPointer; 00366 00367 typedef typename Superclass::TermType TermType; 00368 typedef typename Superclass::TermPointer TermPointer; 00369 00370 typedef typename Superclass::InputImageType InputImageType; 00371 typedef typename Superclass::InputImagePixelType InputImagePixelType; 00372 typedef typename Superclass::InputImageConstPointer InputImageConstPointer; 00373 typedef typename Superclass::InputImageRegionType InputImageRegionType; 00374 typedef typename Superclass::InputPixelRealType InputPixelRealType; 00375 00376 itkStaticConstMacro ( ImageDimension, unsigned int, Superclass::ImageDimension ); 00377 00378 typedef typename Superclass::LevelSetContainerType LevelSetContainerType; 00379 typedef typename Superclass::LevelSetIdentifierType LevelSetIdentifierType; 00380 00381 typedef typename Superclass::LevelSetInputType LevelSetInputType; 00382 typedef typename Superclass::LevelSetOutputType LevelSetOutputType; 00383 typedef typename Superclass::LevelSetOutputRealType LevelSetOutputRealType; 00384 typedef typename Superclass::LevelSetDataType LevelSetDataType; 00385 00386 typedef typename LevelSetType::LayerType LevelSetLayerType; 00387 typedef typename LevelSetType::LayerIterator LevelSetLayerIterator; 00388 00389 typedef typename LevelSetType::LabelMapType LevelSetLabelMapType; 00390 typedef typename LevelSetType::LabelMapPointer LevelSetLabelMapPointer; 00391 00392 00393 typedef typename Superclass::IdListType IdListType; 00394 typedef typename Superclass::IdListIterator IdListIterator; 00395 typedef typename Superclass::IdListImageType IdListImageType; 00396 typedef typename Superclass::CacheImageType CacheImageType; 00397 typedef typename Superclass::DomainMapImageFilterType DomainMapImageFilterType; 00398 00399 typedef typename Superclass::StoppingCriterionType StoppingCriterionType; 00400 typedef typename Superclass::StoppingCriterionPointer StoppingCriterionPointer; 00401 00402 typedef ImageRegionConstIteratorWithIndex< InputImageType > InputImageConstIteratorType; 00403 00404 typedef UpdateMalcolmSparseLevelSet< ImageDimension, EquationContainerType > UpdateLevelSetFilterType; 00405 typedef typename UpdateLevelSetFilterType::Pointer UpdateLevelSetFilterPointer; 00406 00407 protected: 00408 LevelSetEvolution(); 00409 virtual ~LevelSetEvolution(); 00410 00411 virtual void UpdateLevelSets(); 00412 00413 virtual void UpdateEquations(); 00414 00415 private: 00416 LevelSetEvolution( const Self& ); // purposely not implemented 00417 void operator = ( const Self& ); // purposely not implemented 00418 }; 00419 } 00420 00421 #ifndef ITK_MANUAL_INSTANTIATION 00422 #include "itkLevelSetEvolution.hxx" 00423 #endif 00424 00425 #endif // __itkLevelSetEvolution_h 00426