ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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{
162template <typename TInputImage,
163 typename TFeatureImage,
164 typename TOutputImage,
165 typename TFunction,
166 typename TIdCell = unsigned int>
168 : public MultiphaseFiniteDifferenceImageFilter<TInputImage, TFeatureImage, TOutputImage, TFunction, TIdCell>
169{
170public:
171 ITK_DISALLOW_COPY_AND_MOVE(MultiphaseSparseFiniteDifferenceImageFilter);
173
180
182 itkNewMacro(Self);
183
185 itkOverrideGetNameOfClassMacro(MultiphaseSparseFiniteDifferenceImageFilter);
186
187 static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
188
190 using typename Superclass::TimeStepType;
191
193 using typename Superclass::InputImageType;
194 using typename Superclass::InputImagePointer;
195 using typename Superclass::InputRegionType;
196 using typename Superclass::InputSizeType;
197 using typename Superclass::InputSizeValueType;
198 using typename Superclass::InputIndexType;
199 using typename Superclass::InputIndexValueType;
200 using typename Superclass::InputPixelType;
201 using typename Superclass::InputPointType;
202 using typename Superclass::InputSpacingType;
204
205 using typename Superclass::FeatureImageType;
206 using typename Superclass::FeatureSizeType;
207 using typename Superclass::FeatureImagePointer;
208 using typename Superclass::FeatureRegionType;
209 using typename Superclass::FeatureSpacingType;
210 using typename Superclass::FeaturePointType;
211
212 using typename Superclass::OutputImageType;
213 using typename Superclass::OutputImagePointer;
214 using typename Superclass::OutputRegionType;
215 using typename Superclass::OutputSizeType;
216 using typename Superclass::OutputIndexType;
218 using typename Superclass::OutputPixelType;
219
220 using ValueType = typename InputImageType::ValueType;
221 using typename Superclass::IdCellType;
222
225 using FiniteDifferenceFunctionFloatOffsetType = typename FiniteDifferenceFunctionType::FloatOffsetType;
226
229
235
237 using LayerListType = std::vector<LayerPointerType>;
238 using LayerListIterator = typename LayerListType::iterator;
239 using LayerListConstIterator = typename LayerListType::const_iterator;
240
242 using StatusType = signed char;
243
248
251
253
258
260 using UpdateBufferType = std::vector<ValueType>;
261 using UpdateBufferConstIterator = typename UpdateBufferType::const_iterator;
262
265
269 itkSetMacro(NumberOfLayers, unsigned int);
270 itkGetConstMacro(NumberOfLayers, unsigned int);
272
274 itkSetMacro(IsoSurfaceValue, ValueType);
275 itkGetConstMacro(IsoSurfaceValue, ValueType);
277
282 itkSetMacro(InterpolateSurfaceLocation, bool);
283 itkGetConstMacro(InterpolateSurfaceLocation, bool);
284 itkBooleanMacro(InterpolateSurfaceLocation);
286
287 void
289 {
291
292 m_SparseData.resize(this->m_FunctionCount, nullptr);
293
294 for (IdCellType i = 0; i < this->m_FunctionCount; ++i)
295 {
296 m_SparseData[i] = new SparseDataStruct(i);
297 }
298 }
299
303
304protected:
307 {
308 while (!m_SparseData.empty())
309 {
310 delete m_SparseData.back();
311 m_SparseData.pop_back();
312 }
313 }
314
315 void
316 PrintSelf(std::ostream & os, Indent indent) const override;
317
318 // This data structure is created for each phase
346
349
351 std::vector<ValueType> m_PixelDistance{};
352
357 inline virtual ValueType
358 CalculateUpdateValue(const OutputIndexType & 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 {}
394
397 void
399
403 CalculateChange() override;
404
408 void
409 ConstructLayer(SparseDataStruct * sparsePtr, StatusType from, StatusType to);
410
415 void
417
419 void
421
424 void
426
434 void
435 PropagateLayerValues(SparseDataStruct * sparsePtr, StatusType from, StatusType to, StatusType promote, int InOrOut);
436
441 void
443
444 void
445 PropagateFunctionLayerValues(unsigned int functionIndex);
446
450 void
451 UpdateActiveLayerValues(TimeStepType dt, LayerType * StatusUpList, LayerType * StatusDownList);
452
454 void
456 LayerType * OutputList,
457 StatusType ChangeToStatus,
458 StatusType SearchForStatus);
459
461 void
462 ProcessOutsideList(LayerType * OutsideList, StatusType ChangeToStatus);
463
464 void
466
467 virtual void
468 UpdatePixel(unsigned int itkNotUsed(functionIndex),
469 unsigned int itkNotUsed(idx),
470 NeighborhoodIterator<InputImageType> & itkNotUsed(iterator),
471 ValueType & itkNotUsed(newValue),
472 bool & itkNotUsed(status))
473 {}
474
475 itkGetConstMacro(ValueZero, ValueType);
476 itkGetConstMacro(ValueOne, ValueType);
477
481
483 static const ValueType m_ValueOne;
484
486 static const ValueType m_ValueZero;
487
491
495
499
503
507
508 std::vector<SparseDataStruct *> m_SparseData{};
509
513 unsigned int m_NumberOfLayers{};
514
517
520
526
527private:
529
530 double m_RMSSum{ 0. };
531 unsigned int m_RMSCounter{ 0 };
532
536};
537} // end namespace itk
538
539#ifndef ITK_MANUAL_INSTANTIATION
540# include "itkMultiphaseSparseFiniteDifferenceImageFilter.hxx"
541#endif
542
543#endif
Templated n-dimensional image class.
Definition itkImage.h:89
Control indentation during Print() invocation.
Definition itkIndent.h:50
typename FiniteDifferenceFunctionType::FloatOffsetType FiniteDifferenceFunctionFloatOffsetType
void ApplyUpdate(TimeStepType dt) override
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator< StatusImageType > BFCType
void PrintSelf(std::ostream &os, Indent indent) const override
ZeroCrossingImageFilter< InputImageType, InputImageType > ZeroCrossingFilterType
void PropagateLayerValues(SparseDataStruct *sparsePtr, StatusType from, StatusType to, StatusType promote, int InOrOut)
void ProcessStatusList(LayerType *InputList, LayerType *OutputList, StatusType ChangeToStatus, StatusType SearchForStatus)
virtual ValueType CalculateUpdateValue(const OutputIndexType &idx, const TimeStepType &dt, const ValueType &value, const ValueType &change)
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)
MultiphaseFiniteDifferenceImageFilter< TInputImage, TFeatureImage, TOutputImage, TFunction, TIdCell > Superclass
SparseFieldCityBlockNeighborList< NeighborhoodIterator< OutputImageType > > NeighborListType
virtual void UpdatePixel(unsigned int functionIndex, unsigned int idx, NeighborhoodIterator< InputImageType > &iterator, ValueType &newValue, bool &status)
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.
Implements transparent reference counting.
A convenience class for storing indices which reference neighbor pixels within a neighborhood.
A very simple linked list that is used to manage nodes in a layer of a sparse field level-set solver.
SparseFieldLayerIterator< NodeType > Iterator
ConstSparseFieldLayerIterator< NodeType > ConstIterator
This filter finds the closest pixel to the zero-crossings (sign changes) in a signed itk::Image.
#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...