ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkSparseFieldLevelSetImageFilter.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 itkSparseFieldLevelSetImageFilter_h
19 #define itkSparseFieldLevelSetImageFilter_h
20 
22 #include "itkMultiThreader.h"
23 #include "itkSparseFieldLayer.h"
24 #include "itkObjectStore.h"
25 #include <vector>
27 
28 namespace itk
29 {
35 template< typename TValue >
36 class ITK_TEMPLATE_EXPORT SparseFieldLevelSetNode
37 {
38 public:
39  TValue m_Value;
42 };
43 
72 template< typename TNeighborhoodType >
73 class ITK_TEMPLATE_EXPORT SparseFieldCityBlockNeighborList
74 {
75 public:
76  typedef TNeighborhoodType NeighborhoodType;
79  itkStaticConstMacro(Dimension, unsigned int,
82 
83  const RadiusType & GetRadius() const
84  { return m_Radius; }
85 
86  const unsigned int & GetArrayIndex(unsigned int i) const
87  { return m_ArrayIndex[i]; }
88 
89  const OffsetType & GetNeighborhoodOffset(unsigned int i) const
90  { return m_NeighborhoodOffset[i]; }
91 
92  const unsigned int & GetSize() const
93  { return m_Size; }
94 
95  int GetStride(unsigned int i)
96  { return m_StrideTable[i]; }
97 
100 
101  void Print(std::ostream & os) const;
102 
103 private:
104  unsigned int m_Size;
106  std::vector< unsigned int > m_ArrayIndex;
107  std::vector< OffsetType > m_NeighborhoodOffset;
108 
111  unsigned m_StrideTable[Dimension];
112 };
113 
229 template< typename TInputImage, typename TOutputImage >
230 class ITK_TEMPLATE_EXPORT SparseFieldLevelSetImageFilter:
231  public FiniteDifferenceImageFilter< TInputImage, TOutputImage >
232 {
233 public:
234 
240 
242  typedef typename Superclass::TimeStepType TimeStepType;
243  typedef typename Superclass::RadiusType RadiusType;
244  typedef typename Superclass::NeighborhoodScalesType NeighborhoodScalesType;
245 
247  itkNewMacro(Self);
248 
251 
253  typedef TInputImage InputImageType;
254  typedef TOutputImage OutputImageType;
256  itkStaticConstMacro(ImageDimension, unsigned int,
257  TOutputImage::ImageDimension);
258 
262 
265 
269 
271  typedef std::vector< LayerPointerType > LayerListType;
272 
274  typedef signed char StatusType;
275 
280 
284 
286  typedef std::vector< ValueType > UpdateBufferType;
287 
291  itkSetMacro(NumberOfLayers, unsigned int);
292  itkGetConstMacro(NumberOfLayers, unsigned int);
294 
296  itkSetMacro(IsoSurfaceValue, ValueType);
297  itkGetConstMacro(IsoSurfaceValue, ValueType);
299 
303  // itkGetConstMacro(RMSChange, ValueType);
304 
310  itkSetMacro(InterpolateSurfaceLocation, bool);
311  itkGetConstMacro(InterpolateSurfaceLocation, bool);
313 
316  { this->SetInterpolateSurfaceLocation(true); }
318  { this->SetInterpolateSurfaceLocation(false); }
320 
321 #ifdef ITK_USE_CONCEPT_CHECKING
322  // Begin concept checking
323  itkConceptMacro( OutputEqualityComparableCheck,
325  itkConceptMacro( DoubleConvertibleToOutputCheck,
327  itkConceptMacro( OutputOStreamWritableCheck,
329  // End concept checking
330 #endif
331 
332 protected:
334  ~SparseFieldLevelSetImageFilter() ITK_OVERRIDE;
335  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
336 
341  inline virtual ValueType CalculateUpdateValue(
342  const IndexType & itkNotUsed(idx),
343  const TimeStepType & dt,
344  const ValueType & value,
345  const ValueType & change)
346  { return ( value + dt * change ); }
347 
351  virtual void PostProcessOutput() ITK_OVERRIDE;
352 
357  virtual void InitializeBackgroundPixels();
358 
360  void Initialize() ITK_OVERRIDE;
361 
366  void CopyInputToOutput() ITK_OVERRIDE;
367 
369  void AllocateUpdateBuffer() ITK_OVERRIDE;
370 
373  void ApplyUpdate(const TimeStepType& dt) ITK_OVERRIDE;
374 
377  TimeStepType CalculateChange() ITK_OVERRIDE;
378 
382  void ConstructLayer(StatusType from, StatusType to);
383 
388  void ConstructActiveLayer();
389 
391  void InitializeActiveLayerValues();
392 
400  void PropagateLayerValues(StatusType from, StatusType to,
401  StatusType promote, int InOrOut);
402 
407  void PropagateAllLayerValues();
408 
412  void UpdateActiveLayerValues(TimeStepType dt, LayerType *StatusUpList,
413  LayerType *StatusDownList);
414 
416  void ProcessStatusList(LayerType *InputList, LayerType *OutputList,
417  StatusType ChangeToStatus, StatusType SearchForStatus);
418 
420  void ProcessOutsideList(LayerType *OutsideList, StatusType ChangeToStatus);
421 
422  itkGetConstMacro(ValueZero, ValueType);
423  itkGetConstMacro(ValueOne, ValueType);
424 
427  m_NeighborList;
428 
431  double m_ConstantGradientValue;
432 
434  static ValueType m_ValueOne;
435 
437  static ValueType m_ValueZero;
438 
441  static StatusType m_StatusChanging;
442 
445  static StatusType m_StatusActiveChangingUp;
446 
449  static StatusType m_StatusActiveChangingDown;
450 
453  static StatusType m_StatusBoundaryPixel;
454 
457  static StatusType m_StatusNull;
458 
462  typename OutputImageType::Pointer m_ShiftedImage;
463 
468  LayerListType m_Layers;
469 
474  unsigned int m_NumberOfLayers;
475 
477  typename StatusImageType::Pointer m_StatusImage;
478 
480  typename LayerNodeStorageType::Pointer m_LayerNodeStore;
481 
483  ValueType m_IsoSurfaceValue;
484 
487  UpdateBufferType m_UpdateBuffer;
488 
492  // ValueType m_RMSChange;
493 
498  bool m_InterpolateSurfaceLocation;
499 
500  const InputImageType *m_InputImage;
501  OutputImageType *m_OutputImage;
502 
503 private:
504  ITK_DISALLOW_COPY_AND_ASSIGN(SparseFieldLevelSetImageFilter);
505 
508  bool m_BoundsCheckingActive;
509 };
510 } // end namespace itk
511 
512 #ifndef ITK_MANUAL_INSTANTIATION
513 #include "itkSparseFieldLevelSetImageFilter.hxx"
514 #endif
515 
516 #endif
Light weight base class for most itk classes.
Image< StatusType, itkGetStaticConstMacro(ImageDimension) > StatusImageType
A convenience class for storing indices which reference neighbor pixels within a neighborhood.
TPixel ValueType
Definition: itkImage.h:96
This class implements a finite difference partial differential equation solver for evolving surfaces ...
Superclass::RadiusType RadiusType
FiniteDifferenceImageFilter< TInputImage, TOutputImage > Superclass
Superclass::NeighborhoodScalesType NeighborhoodScalesType
SparseFieldLevelSetNode< IndexType > LayerNodeType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
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...
#define itkConceptMacro(name, concept)
A specialized memory management object for allocating and destroying contiguous blocks of objects...
const OffsetType & GetNeighborhoodOffset(unsigned int i) const
Defines iteration of a local N-dimensional neighborhood of pixels across an itk::Image.
Templated n-dimensional image class.
Definition: itkImage.h:75