ITK  4.6.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< typename TEquationContainer, typename TLevelSet >
51 {};
52 
53 template< typename TEquationContainer, typename 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 
121  void SetNumberOfThreads( const ThreadIdType threads );
122 
124  ThreadIdType GetNumberOfThreads() const;
125 
126 protected:
129 
132  virtual void AllocateUpdateBuffer();
133 
135  virtual void ComputeIteration();
136 
138  virtual void ComputeTimeStepForNextIteration();
139 
141  virtual void UpdateLevelSets();
142 
144  virtual void UpdateEquations();
145 
147  void ReinitializeToSignedDistance();
148 
149  typename LevelSetContainerType::Pointer m_UpdateBuffer;
150 
152  typedef LevelSetEvolutionComputeIterationThreader< LevelSetType, ThreadedImageRegionPartitioner< TImage::ImageDimension >, Self > SplitLevelSetComputeIterationThreaderType;
153  typename SplitLevelSetComputeIterationThreaderType::Pointer m_SplitLevelSetComputeIterationThreader;
154 
155  typedef typename DomainMapImageFilterType::DomainMapType::const_iterator DomainMapConstIteratorType;
157  friend class LevelSetEvolutionComputeIterationThreader< LevelSetType, ThreadedDomainMapPartitionerType, Self >;
158  typedef LevelSetEvolutionComputeIterationThreader< LevelSetType, ThreadedDomainMapPartitionerType, Self > SplitDomainMapComputeIterationThreaderType;
159  typename SplitDomainMapComputeIterationThreaderType::Pointer m_SplitDomainMapComputeIterationThreader;
160 
161  friend class LevelSetEvolutionUpdateLevelSetsThreader< LevelSetType, ThreadedImageRegionPartitioner< TImage::ImageDimension >, Self >;
162  typedef LevelSetEvolutionUpdateLevelSetsThreader< LevelSetType, ThreadedImageRegionPartitioner< TImage::ImageDimension >, Self > SplitLevelSetUpdateLevelSetsThreaderType;
163  typename SplitLevelSetUpdateLevelSetsThreaderType::Pointer m_SplitLevelSetUpdateLevelSetsThreader;
164 
166  const IdListType * m_IdListToProcessWhenThreading;
167 };
168 
169 
170 template< typename TEquationContainer, typename TOutput, unsigned int VDimension >
171 class LevelSetEvolution< TEquationContainer, WhitakerSparseLevelSetImage< TOutput, VDimension > > :
172  public LevelSetEvolutionBase< TEquationContainer, WhitakerSparseLevelSetImage< TOutput, VDimension > >
173 {
174 public:
176 
181 
183  itkNewMacro( Self );
184 
187 
189  typedef typename Superclass::EquationContainerPointer EquationContainerPointer;
190  typedef typename Superclass::TermContainerType TermContainerType;
191  typedef typename Superclass::TermContainerPointer TermContainerPointer;
192 
193  typedef typename Superclass::TermType TermType;
194  typedef typename Superclass::TermPointer TermPointer;
195 
196  typedef typename Superclass::InputImageType InputImageType;
197  typedef typename Superclass::InputImagePixelType InputImagePixelType;
198  typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
199  typedef typename Superclass::InputImageRegionType InputImageRegionType;
200  typedef typename Superclass::InputPixelRealType InputPixelRealType;
201 
202  itkStaticConstMacro ( ImageDimension, unsigned int, Superclass::ImageDimension );
203 
205  typedef typename Superclass::LevelSetIdentifierType LevelSetIdentifierType;
206 
207  typedef typename Superclass::LevelSetInputType LevelSetInputType;
208  typedef typename Superclass::LevelSetOutputType LevelSetOutputType;
209  typedef typename Superclass::LevelSetOutputRealType LevelSetOutputRealType;
210  typedef typename Superclass::LevelSetDataType LevelSetDataType;
211 
213 
216 
217 
218  typedef typename Superclass::IdListType IdListType;
219  typedef typename Superclass::IdListIterator IdListIterator;
220  typedef typename Superclass::IdListImageType IdListImageType;
221  typedef typename Superclass::CacheImageType CacheImageType;
222  typedef typename Superclass::DomainMapImageFilterType DomainMapImageFilterType;
223 
224  typedef typename Superclass::StoppingCriterionType StoppingCriterionType;
225  typedef typename Superclass::StoppingCriterionPointer StoppingCriterionPointer;
226 
228 
231 
233  void SetNumberOfThreads( const ThreadIdType threads );
234 
236  ThreadIdType GetNumberOfThreads() const;
237 
238 protected:
241 
242  typedef std::pair< LevelSetInputType, LevelSetOutputType > NodePairType;
243 
244  // For sparse case, the update buffer needs to be the size of the active layer
245  std::map< IdentifierType, LevelSetLayerType* > m_UpdateBuffer;
246 
249  virtual void AllocateUpdateBuffer();
250 
252  virtual void ComputeIteration();
253 
255  virtual void ComputeTimeStepForNextIteration();
256 
258  virtual void UpdateLevelSets();
259 
261  virtual void UpdateEquations();
262 
266  typename SplitLevelSetComputeIterationThreaderType::Pointer m_SplitLevelSetComputeIterationThreader;
267 
268 private:
269  LevelSetEvolution( const Self& );
270  void operator = ( const Self& );
271 };
272 
273 
274 // Shi
275 template< typename TEquationContainer, unsigned int VDimension >
277  TEquationContainer,
278  ShiSparseLevelSetImage< VDimension > > :
279 public LevelSetEvolutionBase< TEquationContainer, ShiSparseLevelSetImage< VDimension > >
280 {
281 public:
283 
288 
290  itkNewMacro( Self );
291 
294 
296  typedef typename Superclass::EquationContainerPointer EquationContainerPointer;
297  typedef typename Superclass::TermContainerType TermContainerType;
298  typedef typename Superclass::TermContainerPointer TermContainerPointer;
299 
300  typedef typename Superclass::TermType TermType;
301  typedef typename Superclass::TermPointer TermPointer;
302 
303  typedef typename Superclass::InputImageType InputImageType;
304  typedef typename Superclass::InputImagePixelType InputImagePixelType;
305  typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
306  typedef typename Superclass::InputImageRegionType InputImageRegionType;
307  typedef typename Superclass::InputPixelRealType InputPixelRealType;
308 
309  itkStaticConstMacro ( ImageDimension, unsigned int, Superclass::ImageDimension );
310 
312  typedef typename Superclass::LevelSetIdentifierType LevelSetIdentifierType;
313 
314  typedef typename Superclass::LevelSetInputType LevelSetInputType;
315  typedef typename Superclass::LevelSetOutputType LevelSetOutputType;
316  typedef typename Superclass::LevelSetOutputRealType LevelSetOutputRealType;
317  typedef typename Superclass::LevelSetDataType LevelSetDataType;
318 
320 
323 
324 
325  typedef typename Superclass::IdListType IdListType;
326  typedef typename Superclass::IdListIterator IdListIterator;
327  typedef typename Superclass::IdListImageType IdListImageType;
328  typedef typename Superclass::CacheImageType CacheImageType;
329  typedef typename Superclass::DomainMapImageFilterType DomainMapImageFilterType;
330 
331  typedef typename Superclass::StoppingCriterionType StoppingCriterionType;
332  typedef typename Superclass::StoppingCriterionPointer StoppingCriterionPointer;
333 
335 
338 
339 protected:
342 
344  virtual void UpdateLevelSets();
345 
347  virtual void UpdateEquations();
348 
349 private:
350  LevelSetEvolution( const Self& );
351  void operator = ( const Self& );
352 };
353 
354 // Malcolm
355 template< typename TEquationContainer, unsigned int VDimension >
356 class LevelSetEvolution< TEquationContainer,
357  MalcolmSparseLevelSetImage< VDimension > > :
358 public LevelSetEvolutionBase< TEquationContainer, MalcolmSparseLevelSetImage< VDimension > >
359 {
360 public:
362 
367 
369  itkNewMacro( Self );
370 
373 
375  typedef typename Superclass::EquationContainerPointer EquationContainerPointer;
376  typedef typename Superclass::TermContainerType TermContainerType;
377  typedef typename Superclass::TermContainerPointer TermContainerPointer;
378 
379  typedef typename Superclass::TermType TermType;
380  typedef typename Superclass::TermPointer TermPointer;
381 
382  typedef typename Superclass::InputImageType InputImageType;
383  typedef typename Superclass::InputImagePixelType InputImagePixelType;
384  typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
385  typedef typename Superclass::InputImageRegionType InputImageRegionType;
386  typedef typename Superclass::InputPixelRealType InputPixelRealType;
387 
388  itkStaticConstMacro ( ImageDimension, unsigned int, Superclass::ImageDimension );
389 
391  typedef typename Superclass::LevelSetIdentifierType LevelSetIdentifierType;
392 
393  typedef typename Superclass::LevelSetInputType LevelSetInputType;
394  typedef typename Superclass::LevelSetOutputType LevelSetOutputType;
395  typedef typename Superclass::LevelSetOutputRealType LevelSetOutputRealType;
396  typedef typename Superclass::LevelSetDataType LevelSetDataType;
397 
400 
403 
404 
405  typedef typename Superclass::IdListType IdListType;
406  typedef typename Superclass::IdListIterator IdListIterator;
407  typedef typename Superclass::IdListImageType IdListImageType;
408  typedef typename Superclass::CacheImageType CacheImageType;
409  typedef typename Superclass::DomainMapImageFilterType DomainMapImageFilterType;
410 
411  typedef typename Superclass::StoppingCriterionType StoppingCriterionType;
412  typedef typename Superclass::StoppingCriterionPointer StoppingCriterionPointer;
413 
415 
418 
419 protected:
421  virtual ~LevelSetEvolution();
422 
423  virtual void UpdateLevelSets();
424 
425  virtual void UpdateEquations();
426 
427 private:
428  LevelSetEvolution( const Self& ); // purposely not implemented
429  void operator = ( const Self& ); // purposely not implemented
430 };
431 }
432 
433 #ifndef ITK_MANUAL_INSTANTIATION
434 #include "itkLevelSetEvolution.hxx"
435 #endif
436 
437 #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 shi 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.
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
LevelSetEvolutionComputeIterationThreader< LevelSetType, SplitLevelSetPartitionerType, Self > SplitLevelSetComputeIterationThreaderType
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.
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
ThreadedIteratorRangePartitioner< typename LevelSetType::LayerConstIterator > SplitLevelSetPartitionerType