ITK  6.0.0
Insight Toolkit
itkMultiphaseSparseFiniteDifferenceImageFilter.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 itkMultiphaseSparseFiniteDifferenceImageFilter_h
19#define itkMultiphaseSparseFiniteDifferenceImageFilter_h
20
27
28#include <vector>
29
30namespace itk
31{
173template <typename TInputImage,
174 typename TFeatureImage,
175 typename TOutputImage,
176 typename TFunction,
177 typename TIdCell = unsigned int>
179 : public MultiphaseFiniteDifferenceImageFilter<TInputImage, TFeatureImage, TOutputImage, TFunction, TIdCell>
180{
181public:
182 ITK_DISALLOW_COPY_AND_MOVE(MultiphaseSparseFiniteDifferenceImageFilter);
191
193 itkNewMacro(Self);
194
196 itkOverrideGetNameOfClassMacro(MultiphaseSparseFiniteDifferenceImageFilter);
197
198 static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
199
201 using typename Superclass::TimeStepType;
202
204 using typename Superclass::InputImageType;
205 using typename Superclass::InputImagePointer;
206 using typename Superclass::InputRegionType;
207 using typename Superclass::InputSizeType;
208 using typename Superclass::InputSizeValueType;
209 using typename Superclass::InputIndexType;
210 using typename Superclass::InputIndexValueType;
211 using typename Superclass::InputPixelType;
212 using typename Superclass::InputPointType;
213 using typename Superclass::InputSpacingType;
214 using typename Superclass::InputOffsetValueType;
215
216 using typename Superclass::FeatureImageType;
217 using typename Superclass::FeatureSizeType;
218 using typename Superclass::FeatureImagePointer;
219 using typename Superclass::FeatureRegionType;
220 using typename Superclass::FeatureSpacingType;
221 using typename Superclass::FeaturePointType;
222
223 using typename Superclass::OutputImageType;
224 using typename Superclass::OutputImagePointer;
225 using typename Superclass::OutputRegionType;
226 using typename Superclass::OutputSizeType;
227 using typename Superclass::OutputIndexType;
228 using typename Superclass::OutputIndexValueType;
229 using typename Superclass::OutputPixelType;
230
231 using ValueType = typename InputImageType::ValueType;
232 using typename Superclass::IdCellType;
233
234 using typename Superclass::FiniteDifferenceFunctionType;
235 using typename Superclass::FiniteDifferenceFunctionPointer;
236 using FiniteDifferenceFunctionFloatOffsetType = typename FiniteDifferenceFunctionType::FloatOffsetType;
237
240
246
248 using LayerListType = std::vector<LayerPointerType>;
249 using LayerListIterator = typename LayerListType::iterator;
250 using LayerListConstIterator = typename LayerListType::const_iterator;
251
253 using StatusType = signed char;
254
259
262
264
269
271 using UpdateBufferType = std::vector<ValueType>;
272 using UpdateBufferConstIterator = typename UpdateBufferType::const_iterator;
273
276
280 itkSetMacro(NumberOfLayers, unsigned int);
281 itkGetConstMacro(NumberOfLayers, unsigned int);
285 itkSetMacro(IsoSurfaceValue, ValueType);
286 itkGetConstMacro(IsoSurfaceValue, ValueType);
293 itkSetMacro(InterpolateSurfaceLocation, bool);
294 itkGetConstMacro(InterpolateSurfaceLocation, bool);
295 itkBooleanMacro(InterpolateSurfaceLocation);
298 void
300 {
301 this->Superclass::SetFunctionCount(n);
302
303 m_SparseData.resize(this->m_FunctionCount, nullptr);
304
305 for (IdCellType i = 0; i < this->m_FunctionCount; ++i)
306 {
307 m_SparseData[i] = new SparseDataStruct(i);
308 }
309 }
310
311#ifdef ITK_USE_CONCEPT_CHECKING
312 // Begin concept checking
316 // End concept checking
317#endif
318
319protected:
322 {
323 while (!m_SparseData.empty())
324 {
325 delete m_SparseData.back();
326 m_SparseData.pop_back();
327 }
328 }
329
330 void
331 PrintSelf(std::ostream & os, Indent indent) const override;
332
333 // This data structure is created for each phase
335 {
337 {
338 m_LayerNodeStore = LayerNodeStorageType::New();
339 m_LayerNodeStore->SetGrowthStrategyToExponential();
340 m_Index = index;
341 }
342
348
351
354
358
360 };
361
363 NeighborListType m_NeighborList{};
364
366 std::vector<ValueType> m_PixelDistance{};
367
372 inline virtual ValueType
373 CalculateUpdateValue(const OutputIndexType & itkNotUsed(idx),
374 const TimeStepType & dt,
375 const ValueType & value,
376 const ValueType & change)
377 {
378 return (value + dt * change);
379 }
380
384 void
386
391 virtual void
393
395 void
396 Initialize() override;
397
402 void
404
406 void
408 {}
409
412 void
414
418 CalculateChange() override;
419
423 void
425
430 void
432
434 void
436
439 void
441
449 void
450 PropagateLayerValues(SparseDataStruct * sparsePtr, StatusType from, StatusType to, StatusType promote, int InOrOut);
451
456 void
458
459 void
460 PropagateFunctionLayerValues(unsigned int functionIndex);
461
465 void
466 UpdateActiveLayerValues(TimeStepType dt, LayerType * StatusUpList, LayerType * StatusDownList);
467
469 void
471 LayerType * OutputList,
472 StatusType ChangeToStatus,
473 StatusType SearchForStatus);
474
476 void
477 ProcessOutsideList(LayerType * OutsideList, StatusType ChangeToStatus);
478
479 void
481
482 virtual void
483 UpdatePixel(unsigned int itkNotUsed(functionIndex),
484 unsigned int itkNotUsed(idx),
485 NeighborhoodIterator<InputImageType> & itkNotUsed(iterator),
486 ValueType & itkNotUsed(newValue),
487 bool & itkNotUsed(status))
488 {}
489
490 itkGetConstMacro(ValueZero, ValueType);
491 itkGetConstMacro(ValueOne, ValueType);
492
496
498 static const ValueType m_ValueOne;
499
501 static const ValueType m_ValueZero;
502
506
510
514
518
522
523 std::vector<SparseDataStruct *> m_SparseData{};
524
528 unsigned int m_NumberOfLayers{};
529
531 ValueType m_IsoSurfaceValue{};
532
534 ValueType m_BackgroundValue{};
535
540 bool m_InterpolateSurfaceLocation{};
541
542private:
543 unsigned int m_CurrentFunctionIndex{};
544
545 double m_RMSSum{ 0. };
546 unsigned int m_RMSCounter{ 0 };
547
550 bool m_BoundsCheckingActive{};
551};
552} // end namespace itk
553
554#ifndef ITK_MANUAL_INSTANTIATION
555# include "itkMultiphaseSparseFiniteDifferenceImageFilter.hxx"
556#endif
557
558#endif
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
This class implements a finite difference partial differential equation solver for evolving surfaces ...
typename FiniteDifferenceFunctionType::FloatOffsetType FiniteDifferenceFunctionFloatOffsetType
void ApplyUpdate(TimeStepType dt) override
void PrintSelf(std::ostream &os, Indent indent) const override
void PropagateLayerValues(SparseDataStruct *sparsePtr, StatusType from, StatusType to, StatusType promote, int InOrOut)
virtual void UpdatePixel(unsigned int, unsigned int, NeighborhoodIterator< InputImageType > &, ValueType &, bool &)
virtual ValueType CalculateUpdateValue(const OutputIndexType &, const TimeStepType &dt, const ValueType &value, const ValueType &change)
void ProcessStatusList(LayerType *InputList, LayerType *OutputList, StatusType ChangeToStatus, StatusType SearchForStatus)
void UpdateActiveLayerValues(TimeStepType dt, LayerType *StatusUpList, LayerType *StatusDownList)
void ConstructLayer(SparseDataStruct *sparsePtr, StatusType from, StatusType to)
void PropagateFunctionLayerValues(unsigned int functionIndex)
void ProcessOutsideList(LayerType *OutsideList, StatusType ChangeToStatus)
Defines iteration of a local N-dimensional neighborhood of pixels across an itk::Image.
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...
The non-const version of the ConstSparseFieldLayerIterator.
A very simple linked list that is used to manage nodes in a layer of a sparse field level-set solver.
This filter finds the closest pixel to the zero-crossings (sign changes) in a signed itk::Image.
static Pointer New()
SmartPointer< Self > Pointer
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Splits an image into a main region and several "face" regions which are used to handle computations o...