ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkMultiphaseSparseFiniteDifferenceImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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  * http://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 
30 namespace itk
31 {
176 template< typename TInputImage, typename TFeatureImage, typename TOutputImage, typename TFunction,
177  typename TIdCell = unsigned int >
179  public MultiphaseFiniteDifferenceImageFilter< TInputImage,
180  TFeatureImage, TOutputImage, TFunction, TIdCell >
181 {
182 public:
183  ITK_DISALLOW_COPY_AND_ASSIGN(MultiphaseSparseFiniteDifferenceImageFilter);
185 
189  TFeatureImage, TOutputImage, TFunction, TIdCell >;
192 
194  itkNewMacro(Self);
195 
198 
199  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
200 
202  using TimeStepType = typename Superclass::TimeStepType;
203 
205  using InputImageType = typename Superclass::InputImageType;
206  using InputImagePointer = typename Superclass::InputImagePointer;
207  using InputRegionType = typename Superclass::InputRegionType;
208  using InputSizeType = typename Superclass::InputSizeType;
209  using InputSizeValueType = typename Superclass::InputSizeValueType;
210  using InputIndexType = typename Superclass::InputIndexType;
211  using InputIndexValueType = typename Superclass::InputIndexValueType;
212  using InputPixelType = typename Superclass::InputPixelType;
213  using InputPointType = typename Superclass::InputPointType;
214  using InputSpacingType = typename Superclass::InputSpacingType;
215  using InputOffsetValueType = typename Superclass::InputOffsetValueType;
216 
217  using FeatureImageType = typename Superclass::FeatureImageType;
218  using FeatureSizeType = typename Superclass::FeatureSizeType;
219  using FeatureImagePointer = typename Superclass::FeatureImagePointer;
220  using FeatureRegionType = typename Superclass::FeatureRegionType;
221  using FeatureSpacingType = typename Superclass::FeatureSpacingType;
222  using FeaturePointType = typename Superclass::FeaturePointType;
223 
224  using OutputImageType = typename Superclass::OutputImageType;
225  using OutputImagePointer = typename Superclass::OutputImagePointer;
226  using OutputRegionType = typename Superclass::OutputRegionType;
227  using OutputSizeType = typename Superclass::OutputSizeType;
228  using OutputIndexType = typename Superclass::OutputIndexType;
229  using OutputIndexValueType = typename Superclass::OutputIndexValueType;
230  using OutputPixelType = typename Superclass::OutputPixelType;
231 
232  using ValueType = typename InputImageType::ValueType;
233  using IdCellType = typename Superclass::IdCellType;
234 
235  using FiniteDifferenceFunctionType = typename Superclass::FiniteDifferenceFunctionType;
236  using FiniteDifferenceFunctionPointer = typename Superclass::FiniteDifferenceFunctionPointer;
237  using FiniteDifferenceFunctionFloatOffsetType = typename FiniteDifferenceFunctionType::FloatOffsetType;
238 
241 
247 
249  using LayerListType = std::vector< LayerPointerType >;
250  using LayerListIterator = typename LayerListType::iterator;
251  using LayerListConstIterator = typename LayerListType::const_iterator;
252 
254  using StatusType = signed char;
255 
258  using StatusImageType =
261 
262  using ZeroCrossingFilterType =
265 
267 
272 
274  using UpdateBufferType = std::vector< ValueType >;
275  using UpdateBufferConstIterator = typename UpdateBufferType::const_iterator;
276 
279 
283  itkSetMacro(NumberOfLayers, unsigned int);
284  itkGetConstMacro(NumberOfLayers, unsigned int);
286 
288  itkSetMacro(IsoSurfaceValue, ValueType);
289  itkGetConstMacro(IsoSurfaceValue, ValueType);
291 
296  itkSetMacro(InterpolateSurfaceLocation, bool);
297  itkGetConstMacro(InterpolateSurfaceLocation, bool);
299 
302  { this->SetInterpolateSurfaceLocation(true); }
304  { this->SetInterpolateSurfaceLocation(false); }
306 
307  void SetFunctionCount(const IdCellType & n)
308  {
309  this->Superclass::SetFunctionCount(n);
310 
311  m_SparseData.resize(this->m_FunctionCount, nullptr);
312 
313  for ( IdCellType i = 0; i < this->m_FunctionCount; i++ )
314  {
315  m_SparseData[i] = new SparseDataStruct(i);
316  }
317  }
318 
319 #ifdef ITK_USE_CONCEPT_CHECKING
320  // Begin concept checking
321  itkConceptMacro( OutputEqualityComparableCheck,
323  itkConceptMacro( DoubleConvertibleToOutputCheck,
325  itkConceptMacro( OutputOStreamWritableCheck,
327  // End concept checking
328 #endif
329 
330 protected:
333  {
334  while ( !m_SparseData.empty() )
335  {
336  delete m_SparseData.back();
337  m_SparseData.pop_back();
338  }
339  }
340 
341  void PrintSelf(std::ostream & os, Indent indent) const override;
342 
343  // This data structure is created for each phase
346  {
347  m_LayerNodeStore = LayerNodeStorageType::New();
348  m_LayerNodeStore->SetGrowthStrategyToExponential();
349  m_Index = index;
350  }
351 
357 
360 
363 
367 
369  };
370 
373 
375  std::vector< ValueType > m_PixelDistance;
376 
382  const OutputIndexType & itkNotUsed(idx),
383  const TimeStepType & dt,
384  const ValueType & value,
385  const ValueType & change)
386  {
387  return ( value + dt * change );
388  }
389 
393  void PostProcessOutput() override;
394 
399  virtual void InitializeBackgroundPixels();
400 
402  void Initialize() override;
403 
408  void CopyInputToOutput() override;
409 
411  void AllocateUpdateBuffer() override {}
412 
415  void ApplyUpdate(TimeStepType dt) override;
416 
419  TimeStepType CalculateChange() override;
420 
424  void ConstructLayer(SparseDataStruct *sparsePtr, StatusType from, StatusType
425  to);
426 
431  void ConstructActiveLayer();
432 
434  void InitializeActiveLayerValues();
435 
438  void InitializeBackgroundConstants();
439 
447  void PropagateLayerValues(SparseDataStruct *sparsePtr, StatusType from,
448  StatusType to, StatusType promote, int InOrOut);
449 
454  void PropagateAllLayerValues();
455 
456  void PropagateFunctionLayerValues(unsigned int functionIndex);
457 
461  void UpdateActiveLayerValues(TimeStepType dt, LayerType *StatusUpList,
462  LayerType *StatusDownList);
463 
465  void ProcessStatusList(LayerType *InputList, LayerType *OutputList,
466  StatusType ChangeToStatus, StatusType SearchForStatus);
467 
469  void ProcessOutsideList(LayerType *OutsideList, StatusType ChangeToStatus);
470 
471  void InitializeIteration() override;
472 
473  virtual void UpdatePixel( unsigned int itkNotUsed(functionIndex), unsigned int itkNotUsed(idx),
474  NeighborhoodIterator< InputImageType > & itkNotUsed(iterator), ValueType & itkNotUsed(
475  newValue),
476  bool & itkNotUsed(status) ){}
477 
478  itkGetConstMacro(ValueZero, ValueType);
479  itkGetConstMacro(ValueOne, ValueType);
480 
483  static double m_ConstantGradientValue;
484 
486  static const ValueType m_ValueOne;
487 
489  static const ValueType m_ValueZero;
490 
494 
498 
502 
506 
509  static const StatusType m_StatusNull;
510 
511  std::vector< SparseDataStruct * > m_SparseData;
512 
516  unsigned int m_NumberOfLayers;
517 
520 
523 
529 
530 private:
532 
533  double m_RMSSum;
534  unsigned int m_RMSCounter;
535 
539 };
540 } // end namespace itk
541 
542 #ifndef ITK_MANUAL_INSTANTIATION
543 #include "itkMultiphaseSparseFiniteDifferenceImageFilter.hxx"
544 #endif
545 
546 #endif
typename OutputImageType::Pointer OutputImagePointer
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
The non-const version of the ConstSparseFieldLayerIterator.
virtual void UpdatePixel(unsigned int, unsigned int, NeighborhoodIterator< InputImageType > &, ValueType &, bool &)
Splits an image into a main region and several &quot;face&quot; regions which are used to handle computations o...
typename FiniteDifferenceFunctionType::FloatOffsetType FiniteDifferenceFunctionFloatOffsetType
TOutputImage OutputImageType
virtual ValueType CalculateUpdateValue(const OutputIndexType &, const TimeStepType &dt, const ValueType &value, const ValueType &change)
typename Superclass::FiniteDifferenceFunctionType FiniteDifferenceFunctionType
This class implements a finite difference partial differential equation solver for evolving surfaces ...
typename Superclass::FiniteDifferenceFunctionPointer FiniteDifferenceFunctionPointer
This filter finds the closest pixel to the zero-crossings (sign changes) in a signed itk::Image...
Control indentation during Print() invocation.
Definition: itkIndent.h:49
A very simple linked list that is used to manage nodes in a layer of a sparse field level-set solver...
#define itkConceptMacro(name, concept)
A specialized memory management object for allocating and destroying contiguous blocks of objects...
Defines iteration of a local N-dimensional neighborhood of pixels across an itk::Image.
Templated n-dimensional image class.
Definition: itkImage.h:75