ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkLevelSetEvolution.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 
19 
20 #ifndef __itkLevelSetEvolution_h
21 #define __itkLevelSetEvolution_h
22 
24 #include "itkLevelSetDenseImage.h"
25 
28 
31 
34 
37 
38 namespace itk
39 {
49 template< class TEquationContainer, class TLevelSet >
51 {};
52 
53 template< class TEquationContainer, class TImage >
54 class LevelSetEvolution< TEquationContainer,
55  LevelSetDenseImage< TImage > > :
56  public LevelSetEvolutionBase< TEquationContainer, LevelSetDenseImage< TImage > >
57 {
58 public:
60 
65 
67  itkNewMacro( Self );
68 
71 
73  typedef typename Superclass::EquationContainerPointer EquationContainerPointer;
74  typedef typename Superclass::TermContainerType TermContainerType;
75  typedef typename Superclass::TermContainerPointer TermContainerPointer;
76 
77  typedef typename Superclass::TermType TermType;
78  typedef typename Superclass::TermPointer TermPointer;
79 
80  typedef typename Superclass::InputImageType InputImageType;
81  typedef typename Superclass::InputImagePixelType InputImagePixelType;
82  typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
83  typedef typename Superclass::InputImageRegionType InputImageRegionType;
84  typedef typename Superclass::InputPixelRealType InputPixelRealType;
85 
86  itkStaticConstMacro ( ImageDimension, unsigned int, Superclass::ImageDimension );
87 
89 
90  typedef typename Superclass::LevelSetIdentifierType LevelSetIdentifierType;
91 
93 
94  typedef typename Superclass::LevelSetOutputType LevelSetOutputType;
95  typedef typename Superclass::LevelSetOutputRealType LevelSetOutputRealType;
96  typedef typename Superclass::LevelSetDataType LevelSetDataType;
97 
99  typedef typename Superclass::IdListIterator IdListIterator;
100  typedef typename Superclass::IdListConstIterator IdListConstIterator;
101  typedef typename Superclass::IdListImageType IdListImageType;
102  typedef typename Superclass::CacheImageType CacheImageType;
103  typedef typename Superclass::DomainMapImageFilterType DomainMapImageFilterType;
104 
105  typedef typename Superclass::StoppingCriterionType StoppingCriterionType;
106  typedef typename Superclass::StoppingCriterionPointer StoppingCriterionPointer;
107 
110 
113 
115 
117 
119 
120 protected:
123 
126  virtual void AllocateUpdateBuffer();
127 
129  virtual void ComputeIteration();
130 
132  virtual void ComputeTimeStepForNextIteration();
133 
135  virtual void UpdateLevelSets();
136 
138  virtual void UpdateEquations();
139 
141  void ReinitializeToSignedDistance();
142 
143  typename LevelSetContainerType::Pointer m_UpdateBuffer;
144 
146  typedef LevelSetEvolutionComputeIterationThreader< LevelSetType, ThreadedImageRegionPartitioner< TImage::ImageDimension >, Self > SplitLevelSetComputeIterationThreaderType;
147  typename SplitLevelSetComputeIterationThreaderType::Pointer m_SplitLevelSetComputeIterationThreader;
148 
149  typedef typename DomainMapImageFilterType::DomainMapType::const_iterator DomainMapConstIteratorType;
151  friend class LevelSetEvolutionComputeIterationThreader< LevelSetType, ThreadedDomainMapPartitionerType, Self >;
152  typedef LevelSetEvolutionComputeIterationThreader< LevelSetType, ThreadedDomainMapPartitionerType, Self > SplitDomainMapComputeIterationThreaderType;
153  typename SplitDomainMapComputeIterationThreaderType::Pointer m_SplitDomainMapComputeIterationThreader;
154 
155  friend class LevelSetEvolutionUpdateLevelSetsThreader< LevelSetType, ThreadedImageRegionPartitioner< TImage::ImageDimension >, Self >;
156  typedef LevelSetEvolutionUpdateLevelSetsThreader< LevelSetType, ThreadedImageRegionPartitioner< TImage::ImageDimension >, Self > SplitLevelSetUpdateLevelSetsThreaderType;
157  typename SplitLevelSetUpdateLevelSetsThreaderType::Pointer m_SplitLevelSetUpdateLevelSetsThreader;
158 
160  const IdListType * m_IdListToProcessWhenThreading;
161 };
162 
163 
164 template< class TEquationContainer, typename TOutput, unsigned int VDimension >
165 class LevelSetEvolution< TEquationContainer, WhitakerSparseLevelSetImage< TOutput, VDimension > > :
166  public LevelSetEvolutionBase< TEquationContainer, WhitakerSparseLevelSetImage< TOutput, VDimension > >
167 {
168 public:
170 
175 
177  itkNewMacro( Self );
178 
181 
183  typedef typename Superclass::EquationContainerPointer EquationContainerPointer;
184  typedef typename Superclass::TermContainerType TermContainerType;
185  typedef typename Superclass::TermContainerPointer TermContainerPointer;
186 
187  typedef typename Superclass::TermType TermType;
188  typedef typename Superclass::TermPointer TermPointer;
189 
190  typedef typename Superclass::InputImageType InputImageType;
191  typedef typename Superclass::InputImagePixelType InputImagePixelType;
192  typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
193  typedef typename Superclass::InputImageRegionType InputImageRegionType;
194  typedef typename Superclass::InputPixelRealType InputPixelRealType;
195 
196  itkStaticConstMacro ( ImageDimension, unsigned int, Superclass::ImageDimension );
197 
199  typedef typename Superclass::LevelSetIdentifierType LevelSetIdentifierType;
200 
201  typedef typename Superclass::LevelSetInputType LevelSetInputType;
202  typedef typename Superclass::LevelSetOutputType LevelSetOutputType;
203  typedef typename Superclass::LevelSetOutputRealType LevelSetOutputRealType;
204  typedef typename Superclass::LevelSetDataType LevelSetDataType;
205 
207 
210 
211 
212  typedef typename Superclass::IdListType IdListType;
213  typedef typename Superclass::IdListIterator IdListIterator;
214  typedef typename Superclass::IdListImageType IdListImageType;
215  typedef typename Superclass::CacheImageType CacheImageType;
216  typedef typename Superclass::DomainMapImageFilterType DomainMapImageFilterType;
217 
218  typedef typename Superclass::StoppingCriterionType StoppingCriterionType;
219  typedef typename Superclass::StoppingCriterionPointer StoppingCriterionPointer;
220 
222 
225 
226 protected:
229 
230  typedef std::pair< LevelSetInputType, LevelSetOutputType > NodePairType;
231 
232  // For sparse case, the update buffer needs to be the size of the active layer
233  std::map< IdentifierType, LevelSetLayerType* > m_UpdateBuffer;
234 
237  virtual void AllocateUpdateBuffer();
238 
240  virtual void ComputeIteration();
241 
243  virtual void ComputeTimeStepForNextIteration();
244 
246  virtual void UpdateLevelSets();
247 
249  virtual void UpdateEquations();
250 
254  typename SplitLevelSetComputeIterationThreaderType::Pointer m_SplitLevelSetComputeIterationThreader;
255 
256 private:
257  LevelSetEvolution( const Self& );
258  void operator = ( const Self& );
259 };
260 
261 
262 // Shi
263 template< class TEquationContainer, unsigned int VDimension >
265  TEquationContainer,
266  ShiSparseLevelSetImage< VDimension > > :
267 public LevelSetEvolutionBase< TEquationContainer, ShiSparseLevelSetImage< VDimension > >
268 {
269 public:
271 
276 
278  itkNewMacro( Self );
279 
282 
284  typedef typename Superclass::EquationContainerPointer EquationContainerPointer;
285  typedef typename Superclass::TermContainerType TermContainerType;
286  typedef typename Superclass::TermContainerPointer TermContainerPointer;
287 
288  typedef typename Superclass::TermType TermType;
289  typedef typename Superclass::TermPointer TermPointer;
290 
291  typedef typename Superclass::InputImageType InputImageType;
292  typedef typename Superclass::InputImagePixelType InputImagePixelType;
293  typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
294  typedef typename Superclass::InputImageRegionType InputImageRegionType;
295  typedef typename Superclass::InputPixelRealType InputPixelRealType;
296 
297  itkStaticConstMacro ( ImageDimension, unsigned int, Superclass::ImageDimension );
298 
300  typedef typename Superclass::LevelSetIdentifierType LevelSetIdentifierType;
301 
302  typedef typename Superclass::LevelSetInputType LevelSetInputType;
303  typedef typename Superclass::LevelSetOutputType LevelSetOutputType;
304  typedef typename Superclass::LevelSetOutputRealType LevelSetOutputRealType;
305  typedef typename Superclass::LevelSetDataType LevelSetDataType;
306 
308 
311 
312 
313  typedef typename Superclass::IdListType IdListType;
314  typedef typename Superclass::IdListIterator IdListIterator;
315  typedef typename Superclass::IdListImageType IdListImageType;
316  typedef typename Superclass::CacheImageType CacheImageType;
317  typedef typename Superclass::DomainMapImageFilterType DomainMapImageFilterType;
318 
319  typedef typename Superclass::StoppingCriterionType StoppingCriterionType;
320  typedef typename Superclass::StoppingCriterionPointer StoppingCriterionPointer;
321 
323 
326 
327 protected:
330 
332  virtual void UpdateLevelSets();
333 
335  virtual void UpdateEquations();
336 
337 private:
338  LevelSetEvolution( const Self& );
339  void operator = ( const Self& );
340 };
341 
342 // Malcolm
343 template< class TEquationContainer, unsigned int VDimension >
344 class LevelSetEvolution< TEquationContainer,
345  MalcolmSparseLevelSetImage< VDimension > > :
346 public LevelSetEvolutionBase< TEquationContainer, MalcolmSparseLevelSetImage< VDimension > >
347 {
348 public:
350 
355 
357  itkNewMacro( Self );
358 
361 
363  typedef typename Superclass::EquationContainerPointer EquationContainerPointer;
364  typedef typename Superclass::TermContainerType TermContainerType;
365  typedef typename Superclass::TermContainerPointer TermContainerPointer;
366 
367  typedef typename Superclass::TermType TermType;
368  typedef typename Superclass::TermPointer TermPointer;
369 
370  typedef typename Superclass::InputImageType InputImageType;
371  typedef typename Superclass::InputImagePixelType InputImagePixelType;
372  typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
373  typedef typename Superclass::InputImageRegionType InputImageRegionType;
374  typedef typename Superclass::InputPixelRealType InputPixelRealType;
375 
376  itkStaticConstMacro ( ImageDimension, unsigned int, Superclass::ImageDimension );
377 
379  typedef typename Superclass::LevelSetIdentifierType LevelSetIdentifierType;
380 
381  typedef typename Superclass::LevelSetInputType LevelSetInputType;
382  typedef typename Superclass::LevelSetOutputType LevelSetOutputType;
383  typedef typename Superclass::LevelSetOutputRealType LevelSetOutputRealType;
384  typedef typename Superclass::LevelSetDataType LevelSetDataType;
385 
388 
391 
392 
393  typedef typename Superclass::IdListType IdListType;
394  typedef typename Superclass::IdListIterator IdListIterator;
395  typedef typename Superclass::IdListImageType IdListImageType;
396  typedef typename Superclass::CacheImageType CacheImageType;
397  typedef typename Superclass::DomainMapImageFilterType DomainMapImageFilterType;
398 
399  typedef typename Superclass::StoppingCriterionType StoppingCriterionType;
400  typedef typename Superclass::StoppingCriterionPointer StoppingCriterionPointer;
401 
403 
406 
407 protected:
409  virtual ~LevelSetEvolution();
410 
411  virtual void UpdateLevelSets();
412 
413  virtual void UpdateEquations();
414 
415 private:
416  LevelSetEvolution( const Self& ); // purposely not implemented
417  void operator = ( const Self& ); // purposely not implemented
418 };
419 }
420 
421 #ifndef ITK_MANUAL_INSTANTIATION
422 #include "itkLevelSetEvolution.hxx"
423 #endif
424 
425 #endif // __itkLevelSetEvolution_h
426