ITK
4.0.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 friend class LevelSetEvolutionUpdateLevelSetsThreader< LevelSetType, ThreadedImageRegionPartitioner< TImage::ImageDimension >, Self >; 00150 typedef LevelSetEvolutionUpdateLevelSetsThreader< LevelSetType, ThreadedImageRegionPartitioner< TImage::ImageDimension >, Self > SplitLevelSetUpdateLevelSetsThreaderType; 00151 typename SplitLevelSetUpdateLevelSetsThreaderType::Pointer m_SplitLevelSetUpdateLevelSetsThreader; 00152 00154 const IdListType * m_IdListToProcessWhenThreading; 00155 }; 00156 00157 00158 template< class TEquationContainer, typename TOutput, unsigned int VDimension > 00159 class LevelSetEvolution< 00160 TEquationContainer, 00161 WhitakerSparseLevelSetImage< TOutput, VDimension > > : 00162 public LevelSetEvolutionBase< 00163 TEquationContainer, 00164 WhitakerSparseLevelSetImage< TOutput, VDimension > > 00165 { 00166 public: 00167 typedef WhitakerSparseLevelSetImage< TOutput, VDimension > LevelSetType; 00168 00169 typedef LevelSetEvolution Self; 00170 typedef SmartPointer< Self > Pointer; 00171 typedef SmartPointer< const Self > ConstPointer; 00172 typedef LevelSetEvolutionBase< TEquationContainer, LevelSetType > Superclass; 00173 00175 itkNewMacro( Self ); 00176 00178 itkTypeMacro( LevelSetEvolution, LevelSetEvolutionBase ); 00179 00180 typedef typename Superclass::EquationContainerType EquationContainerType; 00181 typedef typename Superclass::EquationContainerPointer EquationContainerPointer; 00182 typedef typename Superclass::TermContainerType TermContainerType; 00183 typedef typename Superclass::TermContainerPointer TermContainerPointer; 00184 00185 typedef typename Superclass::TermType TermType; 00186 typedef typename Superclass::TermPointer TermPointer; 00187 00188 typedef typename Superclass::InputImageType InputImageType; 00189 typedef typename Superclass::InputImagePixelType InputImagePixelType; 00190 typedef typename Superclass::InputImageConstPointer InputImageConstPointer; 00191 typedef typename Superclass::InputImageRegionType InputImageRegionType; 00192 typedef typename Superclass::InputPixelRealType InputPixelRealType; 00193 00194 itkStaticConstMacro ( ImageDimension, unsigned int, Superclass::ImageDimension ); 00195 00196 typedef typename Superclass::LevelSetContainerType LevelSetContainerType; 00197 typedef typename Superclass::LevelSetIdentifierType LevelSetIdentifierType; 00198 00199 typedef typename Superclass::LevelSetInputType LevelSetInputType; 00200 typedef typename Superclass::LevelSetOutputType LevelSetOutputType; 00201 typedef typename Superclass::LevelSetOutputRealType LevelSetOutputRealType; 00202 typedef typename Superclass::LevelSetDataType LevelSetDataType; 00203 00204 typedef typename LevelSetType::LayerType LevelSetLayerType; 00205 typedef typename LevelSetType::LayerIterator LevelSetLayerIterator; 00206 00207 typedef typename LevelSetType::LabelMapType LevelSetLabelMapType; 00208 typedef typename LevelSetType::LabelMapPointer LevelSetLabelMapPointer; 00209 00210 00211 typedef typename Superclass::IdListType IdListType; 00212 typedef typename Superclass::IdListIterator IdListIterator; 00213 typedef typename Superclass::IdListImageType IdListImageType; 00214 typedef typename Superclass::CacheImageType CacheImageType; 00215 typedef typename Superclass::DomainMapImageFilterType DomainMapImageFilterType; 00216 00217 typedef typename Superclass::StoppingCriterionType StoppingCriterionType; 00218 typedef typename Superclass::StoppingCriterionPointer StoppingCriterionPointer; 00219 00220 typedef ImageRegionConstIteratorWithIndex< InputImageType > InputImageConstIteratorType; 00221 00222 typedef UpdateWhitakerSparseLevelSet< ImageDimension, LevelSetOutputType, EquationContainerType > UpdateLevelSetFilterType; 00223 typedef typename UpdateLevelSetFilterType::Pointer UpdateLevelSetFilterPointer; 00224 00225 protected: 00226 LevelSetEvolution(); 00227 ~LevelSetEvolution(); 00228 00229 typedef std::pair< LevelSetInputType, LevelSetOutputType > NodePairType; 00230 00231 // For sparse case, the update buffer needs to be the size of the active layer 00232 std::map< IdentifierType, LevelSetLayerType* > m_UpdateBuffer; 00233 00236 virtual void AllocateUpdateBuffer(); 00237 00239 virtual void ComputeIteration(); 00240 00242 virtual void ComputeTimeStepForNextIteration(); 00243 00245 virtual void UpdateLevelSets(); 00246 00248 virtual void UpdateEquations(); 00249 00250 private: 00251 LevelSetEvolution( const Self& ); 00252 void operator = ( const Self& ); 00253 }; 00254 00255 00256 // Shi 00257 template< class TEquationContainer, unsigned int VDimension > 00258 class LevelSetEvolution< 00259 TEquationContainer, 00260 ShiSparseLevelSetImage< VDimension > > : 00261 public LevelSetEvolutionBase< TEquationContainer, ShiSparseLevelSetImage< VDimension > > 00262 { 00263 public: 00264 typedef ShiSparseLevelSetImage< VDimension > LevelSetType; 00265 00266 typedef LevelSetEvolution Self; 00267 typedef SmartPointer< Self > Pointer; 00268 typedef SmartPointer< const Self > ConstPointer; 00269 typedef LevelSetEvolutionBase< TEquationContainer, LevelSetType > Superclass; 00270 00272 itkNewMacro( Self ); 00273 00275 itkTypeMacro( LevelSetEvolution, LevelSetEvolutionBase ); 00276 00277 typedef typename Superclass::EquationContainerType EquationContainerType; 00278 typedef typename Superclass::EquationContainerPointer EquationContainerPointer; 00279 typedef typename Superclass::TermContainerType TermContainerType; 00280 typedef typename Superclass::TermContainerPointer TermContainerPointer; 00281 00282 typedef typename Superclass::TermType TermType; 00283 typedef typename Superclass::TermPointer TermPointer; 00284 00285 typedef typename Superclass::InputImageType InputImageType; 00286 typedef typename Superclass::InputImagePixelType InputImagePixelType; 00287 typedef typename Superclass::InputImageConstPointer InputImageConstPointer; 00288 typedef typename Superclass::InputImageRegionType InputImageRegionType; 00289 typedef typename Superclass::InputPixelRealType InputPixelRealType; 00290 00291 itkStaticConstMacro ( ImageDimension, unsigned int, Superclass::ImageDimension ); 00292 00293 typedef typename Superclass::LevelSetContainerType LevelSetContainerType; 00294 typedef typename Superclass::LevelSetIdentifierType LevelSetIdentifierType; 00295 00296 typedef typename Superclass::LevelSetInputType LevelSetInputType; 00297 typedef typename Superclass::LevelSetOutputType LevelSetOutputType; 00298 typedef typename Superclass::LevelSetOutputRealType LevelSetOutputRealType; 00299 typedef typename Superclass::LevelSetDataType LevelSetDataType; 00300 00301 typedef typename LevelSetType::LayerType LevelSetLayerType; 00302 typedef typename LevelSetType::LayerIterator LevelSetLayerIterator; 00303 00304 typedef typename LevelSetType::LabelMapType LevelSetLabelMapType; 00305 typedef typename LevelSetType::LabelMapPointer LevelSetLabelMapPointer; 00306 00307 00308 typedef typename Superclass::IdListType IdListType; 00309 typedef typename Superclass::IdListIterator IdListIterator; 00310 typedef typename Superclass::IdListImageType IdListImageType; 00311 typedef typename Superclass::CacheImageType CacheImageType; 00312 typedef typename Superclass::DomainMapImageFilterType DomainMapImageFilterType; 00313 00314 typedef typename Superclass::StoppingCriterionType StoppingCriterionType; 00315 typedef typename Superclass::StoppingCriterionPointer StoppingCriterionPointer; 00316 00317 typedef ImageRegionConstIteratorWithIndex< InputImageType > InputImageConstIteratorType; 00318 00319 typedef UpdateShiSparseLevelSet< ImageDimension, EquationContainerType > UpdateLevelSetFilterType; 00320 typedef typename UpdateLevelSetFilterType::Pointer UpdateLevelSetFilterPointer; 00321 00322 protected: 00323 LevelSetEvolution(); 00324 ~LevelSetEvolution(); 00325 00327 virtual void UpdateLevelSets(); 00328 00330 virtual void UpdateEquations(); 00331 00332 private: 00333 LevelSetEvolution( const Self& ); 00334 void operator = ( const Self& ); 00335 }; 00336 00337 // Malcolm 00338 template< class TEquationContainer, unsigned int VDimension > 00339 class LevelSetEvolution< TEquationContainer, 00340 MalcolmSparseLevelSetImage< VDimension > > : 00341 public LevelSetEvolutionBase< TEquationContainer, MalcolmSparseLevelSetImage< VDimension > > 00342 { 00343 public: 00344 typedef MalcolmSparseLevelSetImage< VDimension > LevelSetType; 00345 00346 typedef LevelSetEvolution Self; 00347 typedef SmartPointer< Self > Pointer; 00348 typedef SmartPointer< const Self > ConstPointer; 00349 typedef LevelSetEvolutionBase< TEquationContainer, LevelSetType > Superclass; 00350 00352 itkNewMacro( Self ); 00353 00355 itkTypeMacro( LevelSetEvolution, LevelSetEvolutionBase ); 00356 00357 typedef typename Superclass::EquationContainerType EquationContainerType; 00358 typedef typename Superclass::EquationContainerPointer EquationContainerPointer; 00359 typedef typename Superclass::TermContainerType TermContainerType; 00360 typedef typename Superclass::TermContainerPointer TermContainerPointer; 00361 00362 typedef typename Superclass::TermType TermType; 00363 typedef typename Superclass::TermPointer TermPointer; 00364 00365 typedef typename Superclass::InputImageType InputImageType; 00366 typedef typename Superclass::InputImagePixelType InputImagePixelType; 00367 typedef typename Superclass::InputImageConstPointer InputImageConstPointer; 00368 typedef typename Superclass::InputImageRegionType InputImageRegionType; 00369 typedef typename Superclass::InputPixelRealType InputPixelRealType; 00370 00371 itkStaticConstMacro ( ImageDimension, unsigned int, Superclass::ImageDimension ); 00372 00373 typedef typename Superclass::LevelSetContainerType LevelSetContainerType; 00374 typedef typename Superclass::LevelSetIdentifierType LevelSetIdentifierType; 00375 00376 typedef typename Superclass::LevelSetInputType LevelSetInputType; 00377 typedef typename Superclass::LevelSetOutputType LevelSetOutputType; 00378 typedef typename Superclass::LevelSetOutputRealType LevelSetOutputRealType; 00379 typedef typename Superclass::LevelSetDataType LevelSetDataType; 00380 00381 typedef typename LevelSetType::LayerType LevelSetLayerType; 00382 typedef typename LevelSetType::LayerIterator LevelSetLayerIterator; 00383 00384 typedef typename LevelSetType::LabelMapType LevelSetLabelMapType; 00385 typedef typename LevelSetType::LabelMapPointer LevelSetLabelMapPointer; 00386 00387 00388 typedef typename Superclass::IdListType IdListType; 00389 typedef typename Superclass::IdListIterator IdListIterator; 00390 typedef typename Superclass::IdListImageType IdListImageType; 00391 typedef typename Superclass::CacheImageType CacheImageType; 00392 typedef typename Superclass::DomainMapImageFilterType DomainMapImageFilterType; 00393 00394 typedef typename Superclass::StoppingCriterionType StoppingCriterionType; 00395 typedef typename Superclass::StoppingCriterionPointer StoppingCriterionPointer; 00396 00397 typedef ImageRegionConstIteratorWithIndex< InputImageType > InputImageConstIteratorType; 00398 00399 typedef UpdateMalcolmSparseLevelSet< ImageDimension, EquationContainerType > UpdateLevelSetFilterType; 00400 typedef typename UpdateLevelSetFilterType::Pointer UpdateLevelSetFilterPointer; 00401 00402 protected: 00403 LevelSetEvolution(); 00404 virtual ~LevelSetEvolution(); 00405 00406 virtual void UpdateLevelSets(); 00407 00408 virtual void UpdateEquations(); 00409 00410 private: 00411 LevelSetEvolution( const Self& ); // purposely not implemented 00412 void operator = ( const Self& ); // purposely not implemented 00413 }; 00414 } 00415 00416 #ifndef ITK_MANUAL_INSTANTIATION 00417 #include "itkLevelSetEvolution.hxx" 00418 #endif 00419 00420 #endif // __itkLevelSetEvolution_h 00421