ITK  4.8.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 #ifndef itkLevelSetEvolution_h
19 #define itkLevelSetEvolution_h
20 
22 #include "itkLevelSetDenseImage.h"
23 
26 
29 
32 
35 
36 namespace itk
37 {
47 template< typename TEquationContainer, typename TLevelSet >
49 {};
50 
51 template< typename TEquationContainer, typename TImage >
52 class LevelSetEvolution< TEquationContainer,
53  LevelSetDenseImage< TImage > > :
54  public LevelSetEvolutionBase< TEquationContainer, LevelSetDenseImage< TImage > >
55 {
56 public:
58 
63 
65  itkNewMacro( Self );
66 
69 
71  typedef typename Superclass::EquationContainerPointer EquationContainerPointer;
72  typedef typename Superclass::TermContainerType TermContainerType;
73  typedef typename Superclass::TermContainerPointer TermContainerPointer;
74 
75  typedef typename Superclass::TermType TermType;
76  typedef typename Superclass::TermPointer TermPointer;
77 
78  typedef typename Superclass::InputImageType InputImageType;
79  typedef typename Superclass::InputImagePixelType InputImagePixelType;
80  typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
81  typedef typename Superclass::InputImageRegionType InputImageRegionType;
82  typedef typename Superclass::InputPixelRealType InputPixelRealType;
83 
84  itkStaticConstMacro ( ImageDimension, unsigned int, Superclass::ImageDimension );
85 
87 
88  typedef typename Superclass::LevelSetIdentifierType LevelSetIdentifierType;
89 
91 
92  typedef typename Superclass::LevelSetOutputType LevelSetOutputType;
93  typedef typename Superclass::LevelSetOutputRealType LevelSetOutputRealType;
94  typedef typename Superclass::LevelSetDataType LevelSetDataType;
95 
97  typedef typename Superclass::IdListIterator IdListIterator;
98  typedef typename Superclass::IdListConstIterator IdListConstIterator;
99  typedef typename Superclass::IdListImageType IdListImageType;
100  typedef typename Superclass::CacheImageType CacheImageType;
101  typedef typename Superclass::DomainMapImageFilterType DomainMapImageFilterType;
102 
103  typedef typename Superclass::StoppingCriterionType StoppingCriterionType;
104  typedef typename Superclass::StoppingCriterionPointer StoppingCriterionPointer;
105 
108 
111 
113 
115 
117 
119  void SetNumberOfThreads( const ThreadIdType threads );
120 
122  ThreadIdType GetNumberOfThreads() const;
123 
124 protected:
127 
130  virtual void AllocateUpdateBuffer() ITK_OVERRIDE;
131 
133  virtual void ComputeIteration() ITK_OVERRIDE;
134 
136  virtual void ComputeTimeStepForNextIteration() ITK_OVERRIDE;
137 
139  virtual void UpdateLevelSets() ITK_OVERRIDE;
140 
142  virtual void UpdateEquations() ITK_OVERRIDE;
143 
145  void ReinitializeToSignedDistance();
146 
147  typename LevelSetContainerType::Pointer m_UpdateBuffer;
148 
151  typename SplitLevelSetComputeIterationThreaderType::Pointer m_SplitLevelSetComputeIterationThreader;
152 
153  typedef typename DomainMapImageFilterType::DomainMapType::const_iterator DomainMapConstIteratorType;
155  friend class LevelSetEvolutionComputeIterationThreader< LevelSetType, ThreadedDomainMapPartitionerType, Self >;
156  typedef LevelSetEvolutionComputeIterationThreader< LevelSetType, ThreadedDomainMapPartitionerType, Self > SplitDomainMapComputeIterationThreaderType;
157  typename SplitDomainMapComputeIterationThreaderType::Pointer m_SplitDomainMapComputeIterationThreader;
158 
159  friend class LevelSetEvolutionUpdateLevelSetsThreader< LevelSetType, ThreadedImageRegionPartitioner< TImage::ImageDimension >, Self >;
161  typename SplitLevelSetUpdateLevelSetsThreaderType::Pointer m_SplitLevelSetUpdateLevelSetsThreader;
162 
164  const IdListType * m_IdListToProcessWhenThreading;
165 };
166 
167 
168 template< typename TEquationContainer, typename TOutput, unsigned int VDimension >
169 class LevelSetEvolution< TEquationContainer, WhitakerSparseLevelSetImage< TOutput, VDimension > > :
170  public LevelSetEvolutionBase< TEquationContainer, WhitakerSparseLevelSetImage< TOutput, VDimension > >
171 {
172 public:
174 
179 
181  itkNewMacro( Self );
182 
185 
187  typedef typename Superclass::EquationContainerPointer EquationContainerPointer;
188  typedef typename Superclass::TermContainerType TermContainerType;
189  typedef typename Superclass::TermContainerPointer TermContainerPointer;
190 
191  typedef typename Superclass::TermType TermType;
192  typedef typename Superclass::TermPointer TermPointer;
193 
194  typedef typename Superclass::InputImageType InputImageType;
195  typedef typename Superclass::InputImagePixelType InputImagePixelType;
196  typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
197  typedef typename Superclass::InputImageRegionType InputImageRegionType;
198  typedef typename Superclass::InputPixelRealType InputPixelRealType;
199 
200  itkStaticConstMacro ( ImageDimension, unsigned int, Superclass::ImageDimension );
201 
203  typedef typename Superclass::LevelSetIdentifierType LevelSetIdentifierType;
204 
205  typedef typename Superclass::LevelSetInputType LevelSetInputType;
206  typedef typename Superclass::LevelSetOutputType LevelSetOutputType;
207  typedef typename Superclass::LevelSetOutputRealType LevelSetOutputRealType;
208  typedef typename Superclass::LevelSetDataType LevelSetDataType;
209 
211 
214 
215 
216  typedef typename Superclass::IdListType IdListType;
217  typedef typename Superclass::IdListIterator IdListIterator;
218  typedef typename Superclass::IdListImageType IdListImageType;
219  typedef typename Superclass::CacheImageType CacheImageType;
220  typedef typename Superclass::DomainMapImageFilterType DomainMapImageFilterType;
221 
222  typedef typename Superclass::StoppingCriterionType StoppingCriterionType;
223  typedef typename Superclass::StoppingCriterionPointer StoppingCriterionPointer;
224 
226 
229 
231  void SetNumberOfThreads( const ThreadIdType threads );
232 
234  ThreadIdType GetNumberOfThreads() const;
235 
236 protected:
239 
240  typedef std::pair< LevelSetInputType, LevelSetOutputType > NodePairType;
241 
242  // For sparse case, the update buffer needs to be the size of the active layer
243  std::map< IdentifierType, LevelSetLayerType* > m_UpdateBuffer;
244 
247  virtual void AllocateUpdateBuffer() ITK_OVERRIDE;
248 
250  virtual void ComputeIteration() ITK_OVERRIDE;
251 
253  virtual void ComputeTimeStepForNextIteration() ITK_OVERRIDE;
254 
256  virtual void UpdateLevelSets() ITK_OVERRIDE;
257 
259  virtual void UpdateEquations() ITK_OVERRIDE;
260 
261  typedef ThreadedIteratorRangePartitioner< typename LevelSetType::LayerConstIterator > SplitLevelSetPartitionerType;
262  friend class LevelSetEvolutionComputeIterationThreader< LevelSetType, SplitLevelSetPartitionerType, Self >;
263  typedef LevelSetEvolutionComputeIterationThreader< LevelSetType, SplitLevelSetPartitionerType, Self > SplitLevelSetComputeIterationThreaderType;
264  typename SplitLevelSetComputeIterationThreaderType::Pointer m_SplitLevelSetComputeIterationThreader;
265 
266 private:
267  LevelSetEvolution( const Self& );
268  void operator = ( const Self& );
269 };
270 
271 
272 // Shi
273 template< typename TEquationContainer, unsigned int VDimension >
275  TEquationContainer,
276  ShiSparseLevelSetImage< VDimension > > :
277 public LevelSetEvolutionBase< TEquationContainer, ShiSparseLevelSetImage< VDimension > >
278 {
279 public:
281 
286 
288  itkNewMacro( Self );
289 
292 
294  typedef typename Superclass::EquationContainerPointer EquationContainerPointer;
295  typedef typename Superclass::TermContainerType TermContainerType;
296  typedef typename Superclass::TermContainerPointer TermContainerPointer;
297 
298  typedef typename Superclass::TermType TermType;
299  typedef typename Superclass::TermPointer TermPointer;
300 
301  typedef typename Superclass::InputImageType InputImageType;
302  typedef typename Superclass::InputImagePixelType InputImagePixelType;
303  typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
304  typedef typename Superclass::InputImageRegionType InputImageRegionType;
305  typedef typename Superclass::InputPixelRealType InputPixelRealType;
306 
307  itkStaticConstMacro ( ImageDimension, unsigned int, Superclass::ImageDimension );
308 
310  typedef typename Superclass::LevelSetIdentifierType LevelSetIdentifierType;
311 
312  typedef typename Superclass::LevelSetInputType LevelSetInputType;
313  typedef typename Superclass::LevelSetOutputType LevelSetOutputType;
314  typedef typename Superclass::LevelSetOutputRealType LevelSetOutputRealType;
315  typedef typename Superclass::LevelSetDataType LevelSetDataType;
316 
318 
321 
322 
323  typedef typename Superclass::IdListType IdListType;
324  typedef typename Superclass::IdListIterator IdListIterator;
325  typedef typename Superclass::IdListImageType IdListImageType;
326  typedef typename Superclass::CacheImageType CacheImageType;
327  typedef typename Superclass::DomainMapImageFilterType DomainMapImageFilterType;
328 
329  typedef typename Superclass::StoppingCriterionType StoppingCriterionType;
330  typedef typename Superclass::StoppingCriterionPointer StoppingCriterionPointer;
331 
333 
336 
337 protected:
340 
342  virtual void UpdateLevelSets() ITK_OVERRIDE;
343 
345  virtual void UpdateEquations() ITK_OVERRIDE;
346 
347 private:
348  LevelSetEvolution( const Self& );
349  void operator = ( const Self& );
350 };
351 
352 // Malcolm
353 template< typename TEquationContainer, unsigned int VDimension >
354 class LevelSetEvolution< TEquationContainer,
355  MalcolmSparseLevelSetImage< VDimension > > :
356 public LevelSetEvolutionBase< TEquationContainer, MalcolmSparseLevelSetImage< VDimension > >
357 {
358 public:
360 
365 
367  itkNewMacro( Self );
368 
371 
373  typedef typename Superclass::EquationContainerPointer EquationContainerPointer;
374  typedef typename Superclass::TermContainerType TermContainerType;
375  typedef typename Superclass::TermContainerPointer TermContainerPointer;
376 
377  typedef typename Superclass::TermType TermType;
378  typedef typename Superclass::TermPointer TermPointer;
379 
380  typedef typename Superclass::InputImageType InputImageType;
381  typedef typename Superclass::InputImagePixelType InputImagePixelType;
382  typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
383  typedef typename Superclass::InputImageRegionType InputImageRegionType;
384  typedef typename Superclass::InputPixelRealType InputPixelRealType;
385 
386  itkStaticConstMacro ( ImageDimension, unsigned int, Superclass::ImageDimension );
387 
389  typedef typename Superclass::LevelSetIdentifierType LevelSetIdentifierType;
390 
391  typedef typename Superclass::LevelSetInputType LevelSetInputType;
392  typedef typename Superclass::LevelSetOutputType LevelSetOutputType;
393  typedef typename Superclass::LevelSetOutputRealType LevelSetOutputRealType;
394  typedef typename Superclass::LevelSetDataType LevelSetDataType;
395 
398 
401 
402 
403  typedef typename Superclass::IdListType IdListType;
404  typedef typename Superclass::IdListIterator IdListIterator;
405  typedef typename Superclass::IdListImageType IdListImageType;
406  typedef typename Superclass::CacheImageType CacheImageType;
407  typedef typename Superclass::DomainMapImageFilterType DomainMapImageFilterType;
408 
409  typedef typename Superclass::StoppingCriterionType StoppingCriterionType;
410  typedef typename Superclass::StoppingCriterionPointer StoppingCriterionPointer;
411 
413 
416 
417 protected:
419  virtual ~LevelSetEvolution();
420 
421  virtual void UpdateLevelSets() ITK_OVERRIDE;
422 
423  virtual void UpdateEquations() ITK_OVERRIDE;
424 
425 private:
426  LevelSetEvolution( const Self& ); // purposely not implemented
427  void operator = ( const Self& ); // purposely not implemented
428 };
429 }
430 
431 #ifndef ITK_MANUAL_INSTANTIATION
432 #include "itkLevelSetEvolution.hxx"
433 #endif
434 
435 #endif // itkLevelSetEvolution_h
ImageRegionConstIteratorWithIndex< LevelSetImageType > LevelSetImageConstIteratorType
Light weight base class for most itk classes.
Derived class for the shi representation of level-set function.
TermContainerType::LevelSetContainerType LevelSetContainerType
BinaryThresholdImageFilter< LevelSetImageType, LevelSetImageType > ThresholdFilterType
Superclass::LabelMapType LabelMapType
SignedMaurerDistanceMapImageFilter< LevelSetImageType, LevelSetImageType > MaurerType
Class for partitioning of an ImageRegion.
LevelSetEvolutionBase< TEquationContainer, LevelSetType > Superclass
A multi-dimensional iterator templated over image type that walks an image region and is specialized ...
Class for iterating and evolving the level-set function.
This filter calculates the Euclidean distance transform of a binary image in linear time for arbitrar...
Binarize an input image by thresholding.
Derived class for the Malcolm representation of level-set function.
ImageRegionIteratorWithIndex< LevelSetImageType > LevelSetImageIteratorType
Derived class for the sparse-field representation of level-set function.
UpdateWhitakerSparseLevelSet< ImageDimension, LevelSetOutputType, EquationContainerType > UpdateLevelSetFilterType
A multi-dimensional iterator templated over image type that walks pixels within a region and is speci...
Base class for the &quot;dense&quot; representation of a level-set function on one image.
UpdateMalcolmSparseLevelSet< ImageDimension, EquationContainerType > UpdateLevelSetFilterType
Partitions an iterator range for threading.
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
Base class for updating the level-set function.
Base class for updating the Shi representation of level-set function.
ImageRegionConstIteratorWithIndex< InputImageType > InputImageConstIteratorType
LevelSetContainerType::IdListType IdListType
DomainMapImageFilterType::DomainMapType::const_iterator DomainMapConstIteratorType
TEquationContainer EquationContainerType
UpdateShiSparseLevelSet< ImageDimension, EquationContainerType > UpdateLevelSetFilterType
LevelSetEvolutionBase< TEquationContainer, LevelSetType > Superclass
Base class for updating the Malcolm representation of level-set function.
Class for iterating and evolving the dense level-set function.