ITK  6.0.0
Insight Toolkit
itkSparseFieldLevelSetImageFilter.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 itkSparseFieldLevelSetImageFilter_h
19#define itkSparseFieldLevelSetImageFilter_h
20
23#include "itkSparseFieldLayer.h"
24#include "itkObjectStore.h"
25#include <vector>
27
28namespace itk
29{
35template <typename TValue>
36class ITK_TEMPLATE_EXPORT SparseFieldLevelSetNode
37{
38public:
39 TValue m_Value;
42};
43
72template <typename TNeighborhoodType>
73class ITK_TEMPLATE_EXPORT SparseFieldCityBlockNeighborList
74{
75public:
76 using NeighborhoodType = TNeighborhoodType;
77 using OffsetType = typename NeighborhoodType::OffsetType;
78 using RadiusType = typename NeighborhoodType::RadiusType;
79 static constexpr unsigned int Dimension = NeighborhoodType::Dimension;
80
81 const RadiusType &
82 GetRadius() const
83 {
84 return m_Radius;
85 }
86
87 const unsigned int &
88 GetArrayIndex(unsigned int i) const
89 {
90 return m_ArrayIndex[i];
91 }
92
93 const OffsetType &
94 GetNeighborhoodOffset(unsigned int i) const
95 {
96 return m_NeighborhoodOffset[i];
97 }
98
99 const unsigned int &
100 GetSize() const
101 {
102 return m_Size;
103 }
104
105 int
106 GetStride(unsigned int i)
107 {
108 return m_StrideTable[i];
109 }
110
113
114 void
115 Print(std::ostream & os, Indent indent) const;
116
117private:
118 unsigned int m_Size;
120 std::vector<unsigned int> m_ArrayIndex;
121 std::vector<OffsetType> m_NeighborhoodOffset;
122
125 unsigned int m_StrideTable[Dimension];
126};
127
243template <typename TInputImage, typename TOutputImage>
244class ITK_TEMPLATE_EXPORT SparseFieldLevelSetImageFilter : public FiniteDifferenceImageFilter<TInputImage, TOutputImage>
245{
246public:
247 ITK_DISALLOW_COPY_AND_MOVE(SparseFieldLevelSetImageFilter);
248
254
256 using typename Superclass::TimeStepType;
257 using typename Superclass::RadiusType;
258 using typename Superclass::NeighborhoodScalesType;
259
261 itkNewMacro(Self);
262
264 itkOverrideGetNameOfClassMacro(SparseFieldLevelSetImageFilter);
265
267 using InputImageType = TInputImage;
268 using OutputImageType = TOutputImage;
270 static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
271
274 using ValueType = typename OutputImageType::ValueType;
275
278
282
284 using LayerListType = std::vector<LayerPointerType>;
285
287 using StatusType = signed char;
288
292
296
298 using UpdateBufferType = std::vector<ValueType>;
299
303 itkSetMacro(NumberOfLayers, unsigned int);
304 itkGetConstMacro(NumberOfLayers, unsigned int);
308 itkSetMacro(IsoSurfaceValue, ValueType);
309 itkGetConstMacro(IsoSurfaceValue, ValueType);
315 // itkGetConstMacro(RMSChange, ValueType);
316
322 itkSetMacro(InterpolateSurfaceLocation, bool);
323 itkGetConstMacro(InterpolateSurfaceLocation, bool);
327 void
329 {
330 this->SetInterpolateSurfaceLocation(true);
331 }
332 void
334 {
335 this->SetInterpolateSurfaceLocation(false);
336 }
339#ifdef ITK_USE_CONCEPT_CHECKING
340 // Begin concept checking
344 // End concept checking
345#endif
346
347protected:
350 void
351 PrintSelf(std::ostream & os, Indent indent) const override;
352
357 inline virtual ValueType
358 CalculateUpdateValue(const IndexType & itkNotUsed(idx),
359 const TimeStepType & dt,
360 const ValueType & value,
361 const ValueType & change)
362 {
363 return (value + dt * change);
364 }
365
369 void
371
376 virtual void
378
380 void
381 Initialize() override;
382
387 void
389
391 void
393
396 void
397 ApplyUpdate(const TimeStepType & dt) override;
398
402 CalculateChange() override;
403
407 void
409
414 void
416
418 void
420
428 void
429 PropagateLayerValues(StatusType from, StatusType to, StatusType promote, int InOrOut);
430
435 void
437
441 void
443
445 void
447 LayerType * OutputList,
448 StatusType ChangeToStatus,
449 StatusType SearchForStatus);
450
452 void
453 ProcessOutsideList(LayerType * OutsideList, StatusType ChangeToStatus);
454
455 itkGetConstMacro(ValueZero, ValueType);
456 itkGetConstMacro(ValueOne, ValueType);
457
460
463 double m_ConstantGradientValue{ 1.0 };
464
467
470
474
478
482
486
490
494 typename OutputImageType::Pointer m_ShiftedImage{};
495
500 LayerListType m_Layers{};
501
506 unsigned int m_NumberOfLayers{ 2 };
507
509 typename StatusImageType::Pointer m_StatusImage{};
510
512 typename LayerNodeStorageType::Pointer m_LayerNodeStore{};
513
515 ValueType m_IsoSurfaceValue{};
516
519 UpdateBufferType m_UpdateBuffer{};
520
524 // ValueType m_RMSChange;
525
530 bool m_InterpolateSurfaceLocation{ true };
531
532 const InputImageType * m_InputImage{};
533 OutputImageType * m_OutputImage{};
534
535private:
538 bool m_BoundsCheckingActive{ false };
539};
540} // end namespace itk
541
542#ifndef ITK_MANUAL_INSTANTIATION
543# include "itkSparseFieldLevelSetImageFilter.hxx"
544#endif
545
546#endif
typename FiniteDifferenceFunctionType::TimeStepType TimeStepType
Base class for all process objects that output image data.
Templated n-dimensional image class.
Definition: itkImage.h:89
Control indentation during Print() invocation.
Definition: itkIndent.h:50
A specialized memory management object for allocating and destroying contiguous blocks of objects.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
A convenience class for storing indices which reference neighbor pixels within a neighborhood.
typename NeighborhoodType::RadiusType RadiusType
const OffsetType & GetNeighborhoodOffset(unsigned int i) const
typename NeighborhoodType::OffsetType OffsetType
void Print(std::ostream &os, Indent indent) const
const unsigned int & GetArrayIndex(unsigned int i) const
A very simple linked list that is used to manage nodes in a layer of a sparse field level-set solver.
This class implements a finite difference partial differential equation solver for evolving surfaces ...
void PrintSelf(std::ostream &os, Indent indent) const override
void ApplyUpdate(const TimeStepType &dt) override
typename OutputImageType::IndexType IndexType
virtual ValueType CalculateUpdateValue(const IndexType &, const TimeStepType &dt, const ValueType &value, const ValueType &change)
~SparseFieldLevelSetImageFilter() override=default
void ConstructLayer(StatusType from, StatusType to)
void ProcessStatusList(LayerType *InputList, LayerType *OutputList, StatusType ChangeToStatus, StatusType SearchForStatus)
void PropagateLayerValues(StatusType from, StatusType to, StatusType promote, int InOrOut)
TimeStepType CalculateChange() override
void UpdateActiveLayerValues(TimeStepType dt, LayerType *UpList, LayerType *DownList)
void ProcessOutsideList(LayerType *OutsideList, StatusType ChangeToStatus)
typename OutputImageType::ValueType ValueType
SmartPointer< Self > Pointer
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....