File: itkTopologyPreservingDigitalSurfaceEvolutionImageFilter.h

package info (click to toggle)
itksnap 3.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 10,196 kB
  • ctags: 9,196
  • sloc: cpp: 62,895; sh: 175; makefile: 13
file content (125 lines) | stat: -rw-r--r-- 4,196 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#ifndef __itkTopologyPreservingDigitalSurfaceEvolutionImageFilter_h
#define __itkTopologyPreservingDigitalSurfaceEvolutionImageFilter_h

#include "itkArray.h"
#include "itkInPlaceImageFilter.h"
#include "itkNeighborhoodIterator.h"

#include <deque>

/** \class TopologyPreservingDigitalSurfaceEvolutionImageFilter
 *  
 */

namespace itk
{
template <class TImage>
class TopologyPreservingDigitalSurfaceEvolutionImageFilter
: public InPlaceImageFilter<TImage>
{
public:

  /** Extract dimension from input image. */
  itkStaticConstMacro( ImageDimension,
         unsigned int, TImage::ImageDimension );

  /** Convenient typedefs for simplifying declarations. */
  typedef TImage                                ImageType;

  /** Standard class typedefs. */
  typedef TopologyPreservingDigitalSurfaceEvolutionImageFilter    Self;
  typedef InPlaceImageFilter<ImageType>                           Superclass;
  typedef SmartPointer<Self>                                      Pointer;
  typedef SmartPointer<const Self>                                ConstPointer;

  /** Run-time type information (and related methods) */
  itkTypeMacro( TopologyPreservingDigitalSurfaceEvolutionImageFilter, 
    InPlaceImageFilter );

  /** Method for creation through the object factory. */
  itkNewMacro( Self );

  /** Image typedef support. */
  typedef typename ImageType::PixelType         PixelType;
  typedef typename ImageType::IndexType         IndexType;
  typedef std::deque<IndexType>                 IndexContainerType;
  typedef NeighborhoodIterator<ImageType>       NeighborhoodIteratorType;

  typedef float                                 RealType;

  itkSetObjectMacro( TargetImage, ImageType );
  itkGetObjectMacro( TargetImage, ImageType );

  itkSetMacro( NumberOfIterations, unsigned int );
  itkGetConstMacro( NumberOfIterations, unsigned int );
  
  itkSetMacro( ForegroundValue, PixelType );
  itkGetConstMacro( ForegroundValue, PixelType );
  
  itkSetMacro( UseInversionMode, bool );
  itkGetConstMacro( UseInversionMode, bool );
  
protected:
  TopologyPreservingDigitalSurfaceEvolutionImageFilter();
  virtual ~TopologyPreservingDigitalSurfaceEvolutionImageFilter();
  void PrintSelf( std::ostream& os, Indent indent ) const;
  void GenerateData();

private:
  //purposely not implemented
  TopologyPreservingDigitalSurfaceEvolutionImageFilter( const Self& ); 
  void operator=( const Self& );

  typename ImageType::Pointer                m_TargetImage;
  typename ImageType::Pointer                m_LabelSurfaceImage;

  /**
   * user-selected parameters
   */  
  bool                                       m_UseInversionMode; 
  unsigned int                               m_NumberOfIterations;
  RealType                                   m_ThresholdValue;
  PixelType                                  m_ForegroundValue;
  PixelType                                  m_BackgroundValue;

  /**
   * variables for internal use
   */
  PixelType                                  m_SurfaceLabel;
  IndexContainerType                         m_CriticalConfigurationIndices;

  /**
   * Functions/data for the 2-D case
   */
  void InitializeIndices2D();
  bool IsChangeSafe2D( IndexType );
  bool IsCriticalC1Configuration2D( Array<short> );
  bool IsCriticalC2Configuration2D( Array<short> );
  bool IsCriticalC3Configuration2D( Array<short> );
  bool IsCriticalC4Configuration2D( Array<short> );
  bool IsSpecialCaseOfC4Configuration2D( PixelType, IndexType, 
                                         IndexType, IndexType );

  Array<unsigned int>                        m_RotationIndices[4];
  Array<unsigned int>                        m_ReflectionIndices[2];

  void CreateLabelSurfaceImage();

  void InitializeIndices3D();
  bool IsCriticalC1Configuration3D( Array<short> );
  unsigned int IsCriticalC2Configuration3D( Array<short> );
  bool IsChangeSafe3D( IndexType );

  bool IsCriticalTopologicalConfiguration( IndexType );

  Array<unsigned int>             m_C1Indices[12];
  Array<unsigned int>             m_C2Indices[8];
};

} // end namespace itk

#ifndef ITK_MANUAL_INSTANTIATION
#include "itkTopologyPreservingDigitalSurfaceEvolutionImageFilter.txx"
#endif

#endif