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 template <typename TEquationContainer, typename TImage>
51 class ITK_TEMPLATE_EXPORT LevelSetEvolution<TEquationContainer, LevelSetDenseImage<TImage>>
52  : public LevelSetEvolutionBase<TEquationContainer, LevelSetDenseImage<TImage>>
53 {
54 public:
55  ITK_DISALLOW_COPY_AND_MOVE(LevelSetEvolution);
56 
58 
63 
65  itkNewMacro(Self);
66 
68  itkOverrideGetNameOfClassMacro(LevelSetEvolution);
69 
70  using typename Superclass::EquationContainerType;
71  using typename Superclass::EquationContainerPointer;
72  using typename Superclass::TermContainerType;
73  using typename Superclass::TermContainerPointer;
74 
75  using typename Superclass::TermType;
76  using typename Superclass::TermPointer;
77 
78  using typename Superclass::InputImageType;
79  using typename Superclass::InputImagePixelType;
80  using typename Superclass::InputImageConstPointer;
81  using typename Superclass::InputImageRegionType;
82  using typename Superclass::InputPixelRealType;
83 
84  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
85 
86  using typename Superclass::LevelSetContainerType;
87 
88  using typename Superclass::LevelSetIdentifierType;
89 
91 
92  using typename Superclass::LevelSetOutputType;
93  using typename Superclass::LevelSetOutputRealType;
94  using typename Superclass::LevelSetDataType;
95 
96  using typename Superclass::IdListType;
97  using typename Superclass::IdListIterator;
98  using typename Superclass::IdListConstIterator;
99  using typename Superclass::IdListImageType;
100  using typename Superclass::CacheImageType;
101  using typename Superclass::DomainMapImageFilterType;
102 
103  using typename Superclass::StoppingCriterionType;
104  using typename Superclass::StoppingCriterionPointer;
105 
108 
111 
113 
115 
117 
119  void
120  SetNumberOfWorkUnits(const ThreadIdType numberOfThreads);
121 
124  GetNumberOfWorkUnits() const;
125 
126  ~LevelSetEvolution() override = default;
127 
128 protected:
130 
133  void
134  AllocateUpdateBuffer() override;
135 
137  void
138  ComputeIteration() override;
139 
141  void
142  ComputeTimeStepForNextIteration() override;
143 
145  void
146  UpdateLevelSets() override;
147 
149  void
150  UpdateEquations() override;
151 
153  void
154  ReinitializeToSignedDistance();
155 
156  typename LevelSetContainerType::Pointer m_UpdateBuffer{};
157 
158  friend class LevelSetEvolutionComputeIterationThreader<LevelSetType,
159  ThreadedImageRegionPartitioner<TImage::ImageDimension>,
163  ThreadedImageRegionPartitioner<TImage::ImageDimension>,
164  Self>;
165  typename SplitLevelSetComputeIterationThreaderType::Pointer m_SplitLevelSetComputeIterationThreader{};
166 
167  using DomainMapConstIteratorType = typename DomainMapImageFilterType::DomainMapType::const_iterator;
172  typename SplitDomainMapComputeIterationThreaderType::Pointer m_SplitDomainMapComputeIterationThreader{};
173 
174  friend class LevelSetEvolutionUpdateLevelSetsThreader<LevelSetType,
175  ThreadedImageRegionPartitioner<TImage::ImageDimension>,
179  ThreadedImageRegionPartitioner<TImage::ImageDimension>,
180  Self>;
181  typename SplitLevelSetUpdateLevelSetsThreaderType::Pointer m_SplitLevelSetUpdateLevelSetsThreader{};
182 
184  const IdListType * m_IdListToProcessWhenThreading{};
185 };
186 
187 
188 template <typename TEquationContainer, typename TOutput, unsigned int VDimension>
189 class ITK_TEMPLATE_EXPORT LevelSetEvolution<TEquationContainer, WhitakerSparseLevelSetImage<TOutput, VDimension>>
190  : public LevelSetEvolutionBase<TEquationContainer, WhitakerSparseLevelSetImage<TOutput, VDimension>>
191 {
192 public:
193  ITK_DISALLOW_COPY_AND_MOVE(LevelSetEvolution);
194 
196 
201 
203  itkNewMacro(Self);
204 
206  itkOverrideGetNameOfClassMacro(LevelSetEvolution);
207 
208  using typename Superclass::EquationContainerType;
209  using typename Superclass::EquationContainerPointer;
210  using typename Superclass::TermContainerType;
211  using typename Superclass::TermContainerPointer;
212 
213  using typename Superclass::TermType;
214  using typename Superclass::TermPointer;
215 
216  using typename Superclass::InputImageType;
217  using typename Superclass::InputImagePixelType;
218  using typename Superclass::InputImageConstPointer;
219  using typename Superclass::InputImageRegionType;
220  using typename Superclass::InputPixelRealType;
221 
222  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
223 
224  using typename Superclass::LevelSetContainerType;
225  using typename Superclass::LevelSetIdentifierType;
226 
227  using typename Superclass::LevelSetInputType;
228  using typename Superclass::LevelSetOutputType;
229  using typename Superclass::LevelSetOutputRealType;
230  using typename Superclass::LevelSetDataType;
231 
233 
236 
237 
238  using typename Superclass::IdListType;
239  using typename Superclass::IdListIterator;
240  using typename Superclass::IdListImageType;
241  using typename Superclass::CacheImageType;
242  using typename Superclass::DomainMapImageFilterType;
243 
244  using typename Superclass::StoppingCriterionType;
245  using typename Superclass::StoppingCriterionPointer;
246 
248 
252 
254  void
255  SetNumberOfWorkUnits(const ThreadIdType numberOfWorkUnits);
256 
259  GetNumberOfWorkUnits() const;
260 
261 protected:
263  ~LevelSetEvolution() override;
264 
265  using NodePairType = std::pair<LevelSetInputType, LevelSetOutputType>;
266 
267  // For sparse case, the update buffer needs to be the size of the active layer
268  std::map<IdentifierType, LevelSetLayerType *> m_UpdateBuffer{};
269 
272  void
273  AllocateUpdateBuffer() override;
274 
276  void
277  ComputeIteration() override;
278 
280  void
281  ComputeTimeStepForNextIteration() override;
282 
284  void
285  UpdateLevelSets() override;
286 
288  void
289  UpdateEquations() override;
290 
295  typename SplitLevelSetComputeIterationThreaderType::Pointer m_SplitLevelSetComputeIterationThreader{};
296 };
297 
298 
299 // Shi
300 template <typename TEquationContainer, unsigned int VDimension>
301 class ITK_TEMPLATE_EXPORT LevelSetEvolution<TEquationContainer, ShiSparseLevelSetImage<VDimension>>
302  : public LevelSetEvolutionBase<TEquationContainer, ShiSparseLevelSetImage<VDimension>>
303 {
304 public:
305  ITK_DISALLOW_COPY_AND_MOVE(LevelSetEvolution);
306 
308 
313 
315  itkNewMacro(Self);
316 
318  itkOverrideGetNameOfClassMacro(LevelSetEvolution);
319 
320  using typename Superclass::EquationContainerType;
321  using typename Superclass::EquationContainerPointer;
322  using typename Superclass::TermContainerType;
323  using typename Superclass::TermContainerPointer;
324 
325  using typename Superclass::TermType;
326  using typename Superclass::TermPointer;
327 
328  using typename Superclass::InputImageType;
329  using typename Superclass::InputImagePixelType;
330  using typename Superclass::InputImageConstPointer;
331  using typename Superclass::InputImageRegionType;
332  using typename Superclass::InputPixelRealType;
333 
334  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
335 
336  using typename Superclass::LevelSetContainerType;
337  using typename Superclass::LevelSetIdentifierType;
338 
339  using typename Superclass::LevelSetInputType;
340  using typename Superclass::LevelSetOutputType;
341  using typename Superclass::LevelSetOutputRealType;
342  using typename Superclass::LevelSetDataType;
343 
345 
348 
349 
350  using typename Superclass::IdListType;
351  using typename Superclass::IdListIterator;
352  using typename Superclass::IdListImageType;
353  using typename Superclass::CacheImageType;
354  using typename Superclass::DomainMapImageFilterType;
355 
356  using typename Superclass::StoppingCriterionType;
357  using typename Superclass::StoppingCriterionPointer;
358 
360 
363 
364  LevelSetEvolution() = default;
365  ~LevelSetEvolution() override = default;
366 
367 protected:
369  void
370  UpdateLevelSets() override;
371 
373  void
374  UpdateEquations() override;
375 };
376 
377 // Malcolm
378 template <typename TEquationContainer, unsigned int VDimension>
379 class ITK_TEMPLATE_EXPORT LevelSetEvolution<TEquationContainer, MalcolmSparseLevelSetImage<VDimension>>
380  : public LevelSetEvolutionBase<TEquationContainer, MalcolmSparseLevelSetImage<VDimension>>
381 {
382 public:
383  ITK_DISALLOW_COPY_AND_MOVE(LevelSetEvolution);
384 
386 
391 
393  itkNewMacro(Self);
394 
396  itkOverrideGetNameOfClassMacro(LevelSetEvolution);
397 
398  using typename Superclass::EquationContainerType;
399  using typename Superclass::EquationContainerPointer;
400  using typename Superclass::TermContainerType;
401  using typename Superclass::TermContainerPointer;
402 
403  using typename Superclass::TermType;
404  using typename Superclass::TermPointer;
405 
406  using typename Superclass::InputImageType;
407  using typename Superclass::InputImagePixelType;
408  using typename Superclass::InputImageConstPointer;
409  using typename Superclass::InputImageRegionType;
410  using typename Superclass::InputPixelRealType;
411 
412  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
413 
414  using typename Superclass::LevelSetContainerType;
415  using typename Superclass::LevelSetIdentifierType;
416 
417  using typename Superclass::LevelSetInputType;
418  using typename Superclass::LevelSetOutputType;
419  using typename Superclass::LevelSetOutputRealType;
420  using typename Superclass::LevelSetDataType;
421 
424 
427 
428 
429  using typename Superclass::IdListType;
430  using typename Superclass::IdListIterator;
431  using typename Superclass::IdListImageType;
432  using typename Superclass::CacheImageType;
433  using typename Superclass::DomainMapImageFilterType;
434 
435  using typename Superclass::StoppingCriterionType;
436  using typename Superclass::StoppingCriterionPointer;
437 
439 
442 
443  LevelSetEvolution() = default;
444  ~LevelSetEvolution() override = default;
445 
446 protected:
447  void
448  UpdateLevelSets() override;
449  void
450  UpdateEquations() override;
451 };
452 } // namespace itk
453 
454 #ifndef ITK_MANUAL_INSTANTIATION
455 # include "itkLevelSetEvolution.hxx"
456 #endif
457 
458 #endif // itkLevelSetEvolution_h
itk::LevelSetEvolution< TEquationContainer, ShiSparseLevelSetImage< VDimension > >::LevelSetLayerType
typename LevelSetType::LayerType LevelSetLayerType
Definition: itkLevelSetEvolution.h:344
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:107
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:232
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:90
itkWhitakerSparseLevelSetImage.h
itk::LevelSetEvolution< TEquationContainer, WhitakerSparseLevelSetImage< TOutput, VDimension > >::LevelSetLabelMapPointer
typename LevelSetType::LabelMapPointer LevelSetLabelMapPointer
Definition: itkLevelSetEvolution.h:235
itk::LevelSetEvolution< TEquationContainer, ShiSparseLevelSetImage< VDimension > >::LevelSetLabelMapPointer
typename LevelSetType::LabelMapPointer LevelSetLabelMapPointer
Definition: itkLevelSetEvolution.h:347
itk::LevelSetEvolution< TEquationContainer, MalcolmSparseLevelSetImage< VDimension > >::LevelSetLayerType
typename LevelSetType::LayerType LevelSetLayerType
Definition: itkLevelSetEvolution.h:422
itk::LevelSetEvolutionUpdateLevelSetsThreader
Thread the UpdateLevelSets method.
Definition: itkLevelSetEvolutionUpdateLevelSetsThreader.h:38
itk::LevelSetEvolution< TEquationContainer, ShiSparseLevelSetImage< VDimension > >::UpdateLevelSetFilterPointer
typename UpdateLevelSetFilterType::Pointer UpdateLevelSetFilterPointer
Definition: itkLevelSetEvolution.h:362
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:234
itk::ThreadIdType
unsigned int ThreadIdType
Definition: itkIntTypes.h:102
itk::LevelSetEvolution< TEquationContainer, MalcolmSparseLevelSetImage< VDimension > >::LevelSetLabelMapType
typename LevelSetType::LabelMapType LevelSetLabelMapType
Definition: itkLevelSetEvolution.h:425
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:441
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:346
itk::LevelSetEvolution< TEquationContainer, MalcolmSparseLevelSetImage< VDimension > >::LevelSetLabelMapPointer
typename LevelSetType::LabelMapPointer LevelSetLabelMapPointer
Definition: itkLevelSetEvolution.h:426
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:423
itkLevelSetDenseImage.h
itkShiSparseLevelSetImage.h
itk::LevelSetEvolution< TEquationContainer, WhitakerSparseLevelSetImage< TOutput, VDimension > >::NodePairType
std::pair< LevelSetInputType, LevelSetOutputType > NodePairType
Definition: itkLevelSetEvolution.h:265
itk::LevelSetEvolution< TEquationContainer, WhitakerSparseLevelSetImage< TOutput, VDimension > >::UpdateLevelSetFilterPointer
typename UpdateLevelSetFilterType::Pointer UpdateLevelSetFilterPointer
Definition: itkLevelSetEvolution.h:251
itkUpdateShiSparseLevelSet.h
itk::LevelSetEvolution< TEquationContainer, LevelSetDenseImage< TImage > >::DomainMapConstIteratorType
typename DomainMapImageFilterType::DomainMapType::const_iterator DomainMapConstIteratorType
Definition: itkLevelSetEvolution.h:167
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:110
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