ITK  6.0.0
Insight Toolkit
itkLevelSetEvolution.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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>
48 class ITK_TEMPLATE_EXPORT LevelSetEvolution
49 {};
50 
51 template <typename TEquationContainer, typename TImage>
52 class ITK_TEMPLATE_EXPORT LevelSetEvolution<TEquationContainer, LevelSetDenseImage<TImage>>
53  : public LevelSetEvolutionBase<TEquationContainer, LevelSetDenseImage<TImage>>
54 {
55 public:
56  ITK_DISALLOW_COPY_AND_MOVE(LevelSetEvolution);
57 
59 
64 
66  itkNewMacro(Self);
67 
69  itkOverrideGetNameOfClassMacro(LevelSetEvolution);
70 
71  using typename Superclass::EquationContainerType;
72  using typename Superclass::EquationContainerPointer;
73  using typename Superclass::TermContainerType;
74  using typename Superclass::TermContainerPointer;
75 
76  using typename Superclass::TermType;
77  using typename Superclass::TermPointer;
78 
79  using typename Superclass::InputImageType;
80  using typename Superclass::InputImagePixelType;
81  using typename Superclass::InputImageConstPointer;
82  using typename Superclass::InputImageRegionType;
83  using typename Superclass::InputPixelRealType;
84 
85  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
86 
87  using typename Superclass::LevelSetContainerType;
88 
89  using typename Superclass::LevelSetIdentifierType;
90 
92 
93  using typename Superclass::LevelSetOutputType;
94  using typename Superclass::LevelSetOutputRealType;
95  using typename Superclass::LevelSetDataType;
96 
97  using typename Superclass::IdListType;
98  using typename Superclass::IdListIterator;
99  using typename Superclass::IdListConstIterator;
100  using typename Superclass::IdListImageType;
101  using typename Superclass::CacheImageType;
102  using typename Superclass::DomainMapImageFilterType;
103 
104  using typename Superclass::StoppingCriterionType;
105  using typename Superclass::StoppingCriterionPointer;
106 
109 
112 
114 
116 
118 
120  void
121  SetNumberOfWorkUnits(const ThreadIdType numberOfThreads);
122 
125  GetNumberOfWorkUnits() const;
126 
127  ~LevelSetEvolution() override = default;
128 
129 protected:
131 
134  void
135  AllocateUpdateBuffer() override;
136 
138  void
139  ComputeIteration() override;
140 
142  void
143  ComputeTimeStepForNextIteration() override;
144 
146  void
147  UpdateLevelSets() override;
148 
150  void
151  UpdateEquations() override;
152 
154  void
155  ReinitializeToSignedDistance();
156 
157  typename LevelSetContainerType::Pointer m_UpdateBuffer{};
158 
159  friend class LevelSetEvolutionComputeIterationThreader<LevelSetType,
160  ThreadedImageRegionPartitioner<TImage::ImageDimension>,
164  ThreadedImageRegionPartitioner<TImage::ImageDimension>,
165  Self>;
166  typename SplitLevelSetComputeIterationThreaderType::Pointer m_SplitLevelSetComputeIterationThreader{};
167 
168  using DomainMapConstIteratorType = typename DomainMapImageFilterType::DomainMapType::const_iterator;
173  typename SplitDomainMapComputeIterationThreaderType::Pointer m_SplitDomainMapComputeIterationThreader{};
174 
175  friend class LevelSetEvolutionUpdateLevelSetsThreader<LevelSetType,
176  ThreadedImageRegionPartitioner<TImage::ImageDimension>,
180  ThreadedImageRegionPartitioner<TImage::ImageDimension>,
181  Self>;
182  typename SplitLevelSetUpdateLevelSetsThreaderType::Pointer m_SplitLevelSetUpdateLevelSetsThreader{};
183 
185  const IdListType * m_IdListToProcessWhenThreading{};
186 };
187 
188 
189 template <typename TEquationContainer, typename TOutput, unsigned int VDimension>
190 class ITK_TEMPLATE_EXPORT LevelSetEvolution<TEquationContainer, WhitakerSparseLevelSetImage<TOutput, VDimension>>
191  : public LevelSetEvolutionBase<TEquationContainer, WhitakerSparseLevelSetImage<TOutput, VDimension>>
192 {
193 public:
194  ITK_DISALLOW_COPY_AND_MOVE(LevelSetEvolution);
195 
197 
202 
204  itkNewMacro(Self);
205 
207  itkOverrideGetNameOfClassMacro(LevelSetEvolution);
208 
209  using typename Superclass::EquationContainerType;
210  using typename Superclass::EquationContainerPointer;
211  using typename Superclass::TermContainerType;
212  using typename Superclass::TermContainerPointer;
213 
214  using typename Superclass::TermType;
215  using typename Superclass::TermPointer;
216 
217  using typename Superclass::InputImageType;
218  using typename Superclass::InputImagePixelType;
219  using typename Superclass::InputImageConstPointer;
220  using typename Superclass::InputImageRegionType;
221  using typename Superclass::InputPixelRealType;
222 
223  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
224 
225  using typename Superclass::LevelSetContainerType;
226  using typename Superclass::LevelSetIdentifierType;
227 
228  using typename Superclass::LevelSetInputType;
229  using typename Superclass::LevelSetOutputType;
230  using typename Superclass::LevelSetOutputRealType;
231  using typename Superclass::LevelSetDataType;
232 
234 
237 
238 
239  using typename Superclass::IdListType;
240  using typename Superclass::IdListIterator;
241  using typename Superclass::IdListImageType;
242  using typename Superclass::CacheImageType;
243  using typename Superclass::DomainMapImageFilterType;
244 
245  using typename Superclass::StoppingCriterionType;
246  using typename Superclass::StoppingCriterionPointer;
247 
249 
253 
255  void
256  SetNumberOfWorkUnits(const ThreadIdType numberOfThreads);
257 
260  GetNumberOfWorkUnits() const;
261 
262 protected:
264  ~LevelSetEvolution() override;
265 
266  using NodePairType = std::pair<LevelSetInputType, LevelSetOutputType>;
267 
268  // For sparse case, the update buffer needs to be the size of the active layer
269  std::map<IdentifierType, LevelSetLayerType *> m_UpdateBuffer{};
270 
273  void
274  AllocateUpdateBuffer() override;
275 
277  void
278  ComputeIteration() override;
279 
281  void
282  ComputeTimeStepForNextIteration() override;
283 
285  void
286  UpdateLevelSets() override;
287 
289  void
290  UpdateEquations() override;
291 
296  typename SplitLevelSetComputeIterationThreaderType::Pointer m_SplitLevelSetComputeIterationThreader{};
297 };
298 
299 
300 // Shi
301 template <typename TEquationContainer, unsigned int VDimension>
302 class ITK_TEMPLATE_EXPORT LevelSetEvolution<TEquationContainer, ShiSparseLevelSetImage<VDimension>>
303  : public LevelSetEvolutionBase<TEquationContainer, ShiSparseLevelSetImage<VDimension>>
304 {
305 public:
306  ITK_DISALLOW_COPY_AND_MOVE(LevelSetEvolution);
307 
309 
314 
316  itkNewMacro(Self);
317 
319  itkOverrideGetNameOfClassMacro(LevelSetEvolution);
320 
321  using typename Superclass::EquationContainerType;
322  using typename Superclass::EquationContainerPointer;
323  using typename Superclass::TermContainerType;
324  using typename Superclass::TermContainerPointer;
325 
326  using typename Superclass::TermType;
327  using typename Superclass::TermPointer;
328 
329  using typename Superclass::InputImageType;
330  using typename Superclass::InputImagePixelType;
331  using typename Superclass::InputImageConstPointer;
332  using typename Superclass::InputImageRegionType;
333  using typename Superclass::InputPixelRealType;
334 
335  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
336 
337  using typename Superclass::LevelSetContainerType;
338  using typename Superclass::LevelSetIdentifierType;
339 
340  using typename Superclass::LevelSetInputType;
341  using typename Superclass::LevelSetOutputType;
342  using typename Superclass::LevelSetOutputRealType;
343  using typename Superclass::LevelSetDataType;
344 
346 
349 
350 
351  using typename Superclass::IdListType;
352  using typename Superclass::IdListIterator;
353  using typename Superclass::IdListImageType;
354  using typename Superclass::CacheImageType;
355  using typename Superclass::DomainMapImageFilterType;
356 
357  using typename Superclass::StoppingCriterionType;
358  using typename Superclass::StoppingCriterionPointer;
359 
361 
364 
365  LevelSetEvolution() = default;
366  ~LevelSetEvolution() override = default;
367 
368 protected:
370  void
371  UpdateLevelSets() override;
372 
374  void
375  UpdateEquations() override;
376 };
377 
378 // Malcolm
379 template <typename TEquationContainer, unsigned int VDimension>
380 class ITK_TEMPLATE_EXPORT LevelSetEvolution<TEquationContainer, MalcolmSparseLevelSetImage<VDimension>>
381  : public LevelSetEvolutionBase<TEquationContainer, MalcolmSparseLevelSetImage<VDimension>>
382 {
383 public:
384  ITK_DISALLOW_COPY_AND_MOVE(LevelSetEvolution);
385 
387 
392 
394  itkNewMacro(Self);
395 
397  itkOverrideGetNameOfClassMacro(LevelSetEvolution);
398 
399  using typename Superclass::EquationContainerType;
400  using typename Superclass::EquationContainerPointer;
401  using typename Superclass::TermContainerType;
402  using typename Superclass::TermContainerPointer;
403 
404  using typename Superclass::TermType;
405  using typename Superclass::TermPointer;
406 
407  using typename Superclass::InputImageType;
408  using typename Superclass::InputImagePixelType;
409  using typename Superclass::InputImageConstPointer;
410  using typename Superclass::InputImageRegionType;
411  using typename Superclass::InputPixelRealType;
412 
413  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
414 
415  using typename Superclass::LevelSetContainerType;
416  using typename Superclass::LevelSetIdentifierType;
417 
418  using typename Superclass::LevelSetInputType;
419  using typename Superclass::LevelSetOutputType;
420  using typename Superclass::LevelSetOutputRealType;
421  using typename Superclass::LevelSetDataType;
422 
425 
428 
429 
430  using typename Superclass::IdListType;
431  using typename Superclass::IdListIterator;
432  using typename Superclass::IdListImageType;
433  using typename Superclass::CacheImageType;
434  using typename Superclass::DomainMapImageFilterType;
435 
436  using typename Superclass::StoppingCriterionType;
437  using typename Superclass::StoppingCriterionPointer;
438 
440 
443 
444  LevelSetEvolution() = default;
445  ~LevelSetEvolution() override = default;
446 
447 protected:
448  void
449  UpdateLevelSets() override;
450  void
451  UpdateEquations() override;
452 };
453 } // namespace itk
454 
455 #ifndef ITK_MANUAL_INSTANTIATION
456 # include "itkLevelSetEvolution.hxx"
457 #endif
458 
459 #endif // itkLevelSetEvolution_h
itk::LevelSetEvolution< TEquationContainer, ShiSparseLevelSetImage< VDimension > >::LevelSetLayerType
typename LevelSetType::LayerType LevelSetLayerType
Definition: itkLevelSetEvolution.h:345
itk::WhitakerSparseLevelSetImage
Derived class for the sparse-field representation of level-set function.
Definition: itkWhitakerSparseLevelSetImage.h:41
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itkUpdateMalcolmSparseLevelSet.h
itk::LevelSetEvolution< TEquationContainer, LevelSetDenseImage< TImage > >::ThresholdFilterPointer
typename ThresholdFilterType::Pointer ThresholdFilterPointer
Definition: itkLevelSetEvolution.h:108
itk::ImageRegionConstIteratorWithIndex
A multi-dimensional iterator templated over image type that walks an image region and is specialized ...
Definition: itkImageRegionConstIteratorWithIndex.h:130
itk::LevelSetEvolutionBase< TEquationContainer, LevelSetDenseImage< TImage > >::IdListType
typename LevelSetContainerType::IdListType IdListType
Definition: itkLevelSetEvolutionBase.h:82
itk::LevelSetDenseImage
Base class for the "dense" representation of a level-set function on one image.
Definition: itkLevelSetDenseImage.h:41
itkLevelSetEvolutionUpdateLevelSetsThreader.h
itk::ThreadedImageRegionPartitioner
Class for partitioning of an ImageRegion.
Definition: itkThreadedImageRegionPartitioner.h:45
itk::LevelSetDenseImage::ImageType
TImage ImageType
Definition: itkLevelSetDenseImage.h:47
itk::LevelSetEvolution< TEquationContainer, WhitakerSparseLevelSetImage< TOutput, VDimension > >::LevelSetLayerType
typename LevelSetType::LayerType LevelSetLayerType
Definition: itkLevelSetEvolution.h:233
itk::BinaryThresholdImageFilter
Binarize an input image by thresholding.
Definition: itkBinaryThresholdImageFilter.h:132
itk::LevelSetEvolution< TEquationContainer, LevelSetDenseImage< TImage > >::LevelSetImageType
typename LevelSetType::ImageType LevelSetImageType
Definition: itkLevelSetEvolution.h:91
itkWhitakerSparseLevelSetImage.h
itk::LevelSetEvolution< TEquationContainer, WhitakerSparseLevelSetImage< TOutput, VDimension > >::LevelSetLabelMapPointer
typename LevelSetType::LabelMapPointer LevelSetLabelMapPointer
Definition: itkLevelSetEvolution.h:236
itk::LevelSetEvolution< TEquationContainer, ShiSparseLevelSetImage< VDimension > >::LevelSetLabelMapPointer
typename LevelSetType::LabelMapPointer LevelSetLabelMapPointer
Definition: itkLevelSetEvolution.h:348
itk::LevelSetEvolution< TEquationContainer, MalcolmSparseLevelSetImage< VDimension > >::LevelSetLayerType
typename LevelSetType::LayerType LevelSetLayerType
Definition: itkLevelSetEvolution.h:423
itk::LevelSetEvolutionUpdateLevelSetsThreader
Thread the UpdateLevelSets method.
Definition: itkLevelSetEvolutionUpdateLevelSetsThreader.h:38
itk::LevelSetEvolution< TEquationContainer, ShiSparseLevelSetImage< VDimension > >::UpdateLevelSetFilterPointer
typename UpdateLevelSetFilterType::Pointer UpdateLevelSetFilterPointer
Definition: itkLevelSetEvolution.h:363
itk::LevelSetEvolutionBase
Class for iterating and evolving the dense level-set function.
Definition: itkLevelSetEvolutionBase.h:43
itkLevelSetEvolutionComputeIterationThreader.h
itk::LevelSetSparseImage::LabelMapPointer
typename LabelMapType::Pointer LabelMapPointer
Definition: itkLevelSetSparseImage.h:73
itk::SmartPointer< Self >
itkMalcolmSparseLevelSetImage.h
itk::UpdateWhitakerSparseLevelSet
Base class for updating the level-set function.
Definition: itkUpdateWhitakerSparseLevelSet.h:43
itkLevelSetEvolutionBase.h
itk::LabelMap
Templated n-dimensional image to store labeled objects.
Definition: itkLabelMap.h:70
itk::UpdateMalcolmSparseLevelSet
Base class for updating the Malcolm representation of level-set function.
Definition: itkUpdateMalcolmSparseLevelSet.h:42
itk::LevelSetEvolution< TEquationContainer, WhitakerSparseLevelSetImage< TOutput, VDimension > >::LevelSetLabelMapType
typename LevelSetType::LabelMapType LevelSetLabelMapType
Definition: itkLevelSetEvolution.h:235
itk::ThreadIdType
unsigned int ThreadIdType
Definition: itkIntTypes.h:102
itk::LevelSetEvolution< TEquationContainer, MalcolmSparseLevelSetImage< VDimension > >::LevelSetLabelMapType
typename LevelSetType::LabelMapType LevelSetLabelMapType
Definition: itkLevelSetEvolution.h:426
itk::LevelSetSparseImage::LayerType
std::map< InputType, OutputType, Functor::LexicographicCompare > LayerType
Definition: itkLevelSetSparseImage.h:77
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::LevelSetEvolution< TEquationContainer, MalcolmSparseLevelSetImage< VDimension > >::UpdateLevelSetFilterPointer
typename UpdateLevelSetFilterType::Pointer UpdateLevelSetFilterPointer
Definition: itkLevelSetEvolution.h:442
itk::UpdateShiSparseLevelSet
Base class for updating the Shi representation of level-set function.
Definition: itkUpdateShiSparseLevelSet.h:42
itk::LevelSetSparseImage< int8_t, VDimension >::LayerIterator
typename LayerType::iterator LayerIterator
Definition: itkLevelSetSparseImage.h:78
itk::LevelSetEvolution< TEquationContainer, ShiSparseLevelSetImage< VDimension > >::LevelSetLabelMapType
typename LevelSetType::LabelMapType LevelSetLabelMapType
Definition: itkLevelSetEvolution.h:347
itk::LevelSetEvolution< TEquationContainer, MalcolmSparseLevelSetImage< VDimension > >::LevelSetLabelMapPointer
typename LevelSetType::LabelMapPointer LevelSetLabelMapPointer
Definition: itkLevelSetEvolution.h:427
itk::ImageRegionIteratorWithIndex
A multi-dimensional iterator templated over image type that walks pixels within a region and is speci...
Definition: itkImageRegionIteratorWithIndex.h:73
itk::LevelSetEvolution< TEquationContainer, MalcolmSparseLevelSetImage< VDimension > >::LevelSetLayerIterator
typename LevelSetType::LayerIterator LevelSetLayerIterator
Definition: itkLevelSetEvolution.h:424
itkLevelSetDenseImage.h
itkShiSparseLevelSetImage.h
itk::LevelSetEvolution< TEquationContainer, WhitakerSparseLevelSetImage< TOutput, VDimension > >::NodePairType
std::pair< LevelSetInputType, LevelSetOutputType > NodePairType
Definition: itkLevelSetEvolution.h:266
itk::LevelSetEvolution< TEquationContainer, WhitakerSparseLevelSetImage< TOutput, VDimension > >::UpdateLevelSetFilterPointer
typename UpdateLevelSetFilterType::Pointer UpdateLevelSetFilterPointer
Definition: itkLevelSetEvolution.h:252
itkUpdateShiSparseLevelSet.h
itk::LevelSetEvolution< TEquationContainer, LevelSetDenseImage< TImage > >::DomainMapConstIteratorType
typename DomainMapImageFilterType::DomainMapType::const_iterator DomainMapConstIteratorType
Definition: itkLevelSetEvolution.h:168
itk::ShiSparseLevelSetImage
Derived class for the shi representation of level-set function.
Definition: itkShiSparseLevelSetImage.h:37
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::LevelSetEvolution< TEquationContainer, LevelSetDenseImage< TImage > >::MaurerPointer
typename MaurerType::Pointer MaurerPointer
Definition: itkLevelSetEvolution.h:111
itkUpdateWhitakerSparseLevelSet.h
itk::LevelSetEvolution
Class for iterating and evolving the level-set function.
Definition: itkLevelSetEvolution.h:48
itk::ThreadedIteratorRangePartitioner
Partitions an iterator range for threading.
Definition: itkThreadedIteratorRangePartitioner.h:112
itk::MalcolmSparseLevelSetImage
Derived class for the Malcolm representation of level-set function.
Definition: itkMalcolmSparseLevelSetImage.h:41
itk::SignedMaurerDistanceMapImageFilter
This filter calculates the Euclidean distance transform of a binary image in linear time for arbitrar...
Definition: itkSignedMaurerDistanceMapImageFilter.h:67
itk::LevelSetEvolutionComputeIterationThreader
Thread the ComputeIteration method.
Definition: itkLevelSetEvolutionComputeIterationThreader.h:40