Slicer  5.2
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SkelGraph.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Extract Skeleton
4  Module: $HeadURL$
5  Language: C++
6  Date: $Date$
7  Version: $Revision$
8 
9  Copyright (c) Brigham and Women's Hospital (BWH) All Rights Reserved.
10 
11  See License.txt or http://www.slicer.org/copyright/copyright.txt for details.
12 
13 ==========================================================================*/
14 #ifndef _SKEL_GRAPH_H_
15 #define _SKEL_GRAPH_H_
16 
17 #include <deque>
18 #include <list>
19 #include "coordTypes.h"
20 
22  {
24  {
25  branchID = -1;
26  length = 0;
27  acc_length = 0;
28  max_path_length = 0;
29  }
30  int branchID; // == position in m_Graph
31  double length; // length between end points
32  std::deque<Coord3i> points;
33 
34  double acc_length; // for temporary use when searching maximal path
35  std::deque<int> acc_path;
36 
38  std::deque<int> max_path; // maximal path
39 
42  std::deque<int> end_1_neighbors; // id's == one can use advance for random access
43  std::deque<int> end_2_neighbors;
44  };
45 
46 class SkelGraph
47 {
48 public:
49  SkelGraph();
50  virtual ~SkelGraph();
51 
52  // Print info on all m_Graph nodes to standard output
53  void PrintGraph();
54 
55  // Extract skeletal m_Graph
56  // Limitation: currently image spacing is not taken into account.
57  // If image spacing is highly anisotropic then longest path computation
58  // may not give optimal results, and sampling distance (when calling
59  // SampleAlongMaximalPath) may be uneven.
60  void ExtractSkeletalGraph(const unsigned char *image, const int dim[3], const double spacing[3]);
61 
62  // Extract maximal path between 2 points in the m_Graph
63  void FindMaximalPath();
64 
65  // Sample points along the maximal path.
66  // requestedNumberOfPoints is an approximate number of points to be returned.
67  void SampleAlongMaximalPath(int requestedNumberOfPoints, std::deque<Coord3i> &axis_points);
68 
69 private:
70 
71  // private routines
72 
73  // adds a new element with default values to To_do list
74  skel_branch* AddNewBranchToDo(std::list<skel_branch> &branchesToDo);
75 
76  // find all endpoints in image
77  void FindEndpoints(std::deque<Coord3i> &endPoints, const unsigned char *image, const int dim[3]);
78 
79  // tests whether (x,y,z) is an endpoint
80  int IsEndpoint(int x, int y, int z, const unsigned char *image, const int dim[3]);
81 
82  // returns a list of valid neighbors at act_point
83  // points that exist in skeleton, but are yet unlabeled
84  void GetValidNeighbors(int* label_image, Coord3i &act_point, std::deque<Coord3i> &neighbors, const unsigned char *image, const int dim[3]);
85 
86  void ResetGraph();
87 
88  // Extracted Graph
89  std::deque<skel_branch> m_Graph;
90 
91  // To_Do list, only of temporary use for extract m_Graph
92  //std::deque<skel_branch> * branchesToDo;
93 
94  // List of branch IDs that make up the longest path
95  std::deque<int> m_MaximalPath;
96  double m_MaximalPathLength;
97  double m_Spacing[3];
98 
99 };
100 
101 #endif
Coord3i end_1_point
Definition: SkelGraph.h:40
std::deque< Coord3i > points
Definition: SkelGraph.h:32
double max_path_length
Definition: SkelGraph.h:37
virtual ~SkelGraph()
Coord3i end_2_point
Definition: SkelGraph.h:41
void ExtractSkeletalGraph(const unsigned char *image, const int dim[3], const double spacing[3])
double length
Definition: SkelGraph.h:31
void FindMaximalPath()
std::deque< int > end_1_neighbors
Definition: SkelGraph.h:42
double acc_length
Definition: SkelGraph.h:34
void PrintGraph()
int branchID
Definition: SkelGraph.h:30
std::deque< int > max_path
Definition: SkelGraph.h:38
std::deque< int > acc_path
Definition: SkelGraph.h:35
void SampleAlongMaximalPath(int requestedNumberOfPoints, std::deque< Coord3i > &axis_points)
std::deque< int > end_2_neighbors
Definition: SkelGraph.h:43