public class MTBNeuriteSkelGraph extends MTBGraph
The class implements a neurite skeleton graph (NSG), based on the skeleton of a neurite region. The NSG is directed, in the way that exact one START node (mostly the point near the neuron cell body area) exists, which can have one or more output edges and no input edges. By the way, there are some other nodes from type BRANCH or END inside the graph. BRANCH nodes: have one input edge and two or more out edges END nodes: have exact one input edge and no output edges The NSG is build by skeleton traversing, beginning at one given node. The direction is implicit corrected, so that at every time there is a direct "flow" from the START node to all END nodes. So the START node is connected with every END node via exact one path. If the START nodes is changed, the directness of the graph is automatically corrected, and the old node becomes automatically a BRANCH or a END node. The edges hold the pixels of the skeleton between the nodes. It is possible to get all paths from the START node to all END nodes, get the longest path in the whole graph, and several other operations, needed for a NSG. The graph is always free of circles. If an circle exists in the underlying skeleton, the circle is disconnected in two paths (due to the approach of building the graph).
MTBGraph
,
MTBGraphEdge
,
MTBNeuriteSkelGraphNode
Modifier and Type | Field and Description |
---|---|
private int |
background_color |
private int |
color_graphEdge
Color of graph edge points.
|
private int |
color_graphNode
Color of graph node points.
|
private int |
color_skelBranch
Color of pre-detected branch points.
|
private int |
color_skelSpecial
Color of pre-detected special points, for example a 2x2 skeleton region.
|
private int |
color_skelVisitB
Color of visited graph branch points.
|
private int |
color_skelVisitE
Color of visited graph edge points.
|
private int[][] |
delta
X- and Y-coordinate differences of the 8-way neighbors.
|
private int |
height
Skeleton image size in y-direction.
|
private int |
maxSpineLength |
private int |
regionID
Region ID of the corresponding neurite region to this neurite skeleton
graph.
|
private int |
skeleton_color
The color of the skeleton in the binary image.
|
private int |
width
Skeleton image size in x-direction.
|
directed, edges, nodes, numberOfEdges, numberOfNodes
Constructor and Description |
---|
MTBNeuriteSkelGraph()
Standard constructor.
|
MTBNeuriteSkelGraph(int _maxSpineLength)
Constructor that creates an empty directed MTBNeuriteSkelGraph with defined
maximum spine length.
|
MTBNeuriteSkelGraph(Vector<MTBNeuriteSkelGraphNode<Point2D.Double>> skelNodes,
Vector<MTBGraphEdge> skelEdges,
int _maxSpineLength,
int _width,
int _heigth)
Constructor to create an directed MTBNeuriteSkelGraph with the given
MTBSkeletonGraphNodes and MTBGraphEdges.
|
Modifier and Type | Method and Description |
---|---|
private boolean |
build(int xx,
int yy,
MTBImageByte skelImg,
MTBNeuriteSkelGraphNode<Point2D.Double> parentNode)
Internal method to create the graph from the skeleton image.
|
boolean |
buildSkeletonGraph(int x,
int y,
int w,
int h,
MTBImageByte skeletonImg,
int skelColor)
Build the skeleton graph from a given binary skeleton image and a given
starting point to build up the graph.
|
MTBNeuriteSkelGraph |
clone() |
private void |
correctDirectness(MTBNeuriteSkelGraphNode<Point2D.Double> rootNode)
Method to correct the direction of every edge inside the skeleton graph
from a given root node.
|
private void |
depthFirstSearch(Vector<Point2D.Double> pixels,
Vector<Integer> parents,
MTBNeuriteSkelGraphNode<Point2D.Double> startNode,
int label)
Depth-first-search to collect data from the neurite skeleton graph in a SWC
file like format.
|
Vector<Vector<Point2D.Double>> |
getAllPaths(boolean includeSpines)
Get the pixels of all paths of the neurite skeleton graph.
|
void |
getAllPixels(Vector<Point2D.Double> pixels)
Get all pixels of the neurite skeleton graph from the nodes and edges.
|
private void |
getAllPixels(Vector<Point2D.Double> pixels,
MTBNeuriteSkelGraphNode<Point2D.Double> tmpNode)
Get all pixels of the neurite skeleton graph from the nodes and edges.
|
Vector<MTBNeuriteSkelGraphNode<Point2D.Double>> |
getBranchNodes()
Get all branch nodes of the MTBNeuriteSkelGraph.
|
Vector<MTBNeuriteSkelGraphNode<Point2D.Double>> |
getEndNodes()
Get all end nodes of the MTBNeuriteSkelGraph.
|
int |
getHeight()
Get skeleton graph image size in y direction.
|
Vector<Point2D.Double> |
getLongestPath(boolean includeSpines)
Get the pixels of the longest path of the neurite skeleton graph.
|
private void |
getPath(Vector<Point2D.Double> p,
MTBNeuriteSkelGraphNode<Point2D.Double> n)
Internal method to traverse the path and return the pixel list.
|
int |
getRegionID()
Get the region id.
|
Vector<Point2D.Double> |
getShortestPath(boolean includeSpines)
Get the pixels of the shortest path of the neurite skeleton graph.
|
Vector<MTBNeuriteSkelGraphNode<Point2D.Double>> |
getSkeletonGraphNodes()
Get all nodes of the MTBNeuriteSkelGraph as MTBNeuriteSkelGraphNodes.
|
Vector<Vector<Point2D.Double>> |
getSpinePaths()
Get the pixels of all spine paths of the neurite skeleton graph.
|
MTBNeuriteSkelGraphNode<Point2D.Double> |
getStartNode()
Get the start node of the MTBNeuriteSkelGraph.
|
int |
getWidth()
Get skeleton graph image size in x direction.
|
private MTBImageByte |
markBranchPoints(MTBImageByte skelImg)
Mark branch/special points as first step before building up the whole
skeleton graph.
|
void |
print()
Print the neurite skeleton graph informations.
|
void |
setRegionID(int id)
Set the region id.
|
void |
setStartNode(MTBNeuriteSkelGraphNode<Point2D.Double> node)
Set a new start node.
|
MTBImageByte |
toByteImage()
Draw the skeleton graph into a binary image.
|
MTBImageRGB |
toImage()
Visualize the skeleton graph as RGB image.
|
MTBImageRGB |
toImage(MTBImageRGB rgbImage)
Draw the skeleton graph in the given RGB image.
|
MTBTableModel |
toSWC(String fileName,
MTBImageByte neuronImage)
Method to save neurite skeleton graph as SWC file.
|
addEdge, addNode, getEdgeNum, getEdges, getGraphCost, getNodeNum, getNodes, isDirected, removeEdge, removeNode
private int width
private int height
private int regionID
private int skeleton_color
private int background_color
private final int color_skelBranch
private final int color_skelSpecial
private final int color_graphEdge
private final int color_graphNode
private final int color_skelVisitE
private final int color_skelVisitB
private final int[][] delta
private int maxSpineLength
public MTBNeuriteSkelGraph()
public MTBNeuriteSkelGraph(int _maxSpineLength)
_maxSpineLength
- public MTBNeuriteSkelGraph(Vector<MTBNeuriteSkelGraphNode<Point2D.Double>> skelNodes, Vector<MTBGraphEdge> skelEdges, int _maxSpineLength, int _width, int _heigth) throws MTBNeuriteSkelGraphException
skelNodes
- vector of MTBNeuriteSkelGraphNodesskelEdges
- vector of MTBGraphEdgesMTBNeuriteSkelGraphException
public int getWidth()
public int getHeight()
public MTBNeuriteSkelGraph clone()
public Vector<MTBNeuriteSkelGraphNode<Point2D.Double>> getSkeletonGraphNodes()
public MTBNeuriteSkelGraphNode<Point2D.Double> getStartNode()
public void setStartNode(MTBNeuriteSkelGraphNode<Point2D.Double> node)
node
- new start nodepublic Vector<MTBNeuriteSkelGraphNode<Point2D.Double>> getBranchNodes()
public Vector<MTBNeuriteSkelGraphNode<Point2D.Double>> getEndNodes()
public void setRegionID(int id)
public int getRegionID()
public boolean buildSkeletonGraph(int x, int y, int w, int h, MTBImageByte skeletonImg, int skelColor)
Build the skeleton graph from a given binary skeleton image and a given starting point to build up the graph. Build definition: The graph is build from a given starting point (mostly a end point of the skeleton, near the neuron cell body). All other points are marked automatically by building up the graph. Branch points are marked as BRANCH nodes, end points are marked as END nodes and edge points are added to the edge data structure. BRANCH nodes: have one input edge and two or more out edges END nodes: have exact one input edge and no output edges By building up the graph, 4-way neighbors are visited first, diagonal neighbors are visited in the second step. The graph is always free of circles. If an circle exists in the underlying skeleton, the circle is disconnected in two paths (due to the approach of building the graph).
x
- starting point coordinate in x-directiony
- starting point coordinate in y-directionw
- width of the skeleton imageh
- height of the skeleton imageskeletonImg
- the binary skeleton imageskelColor
- color of the skeleton, the background is set to the opposite
color, for example the skeleton is 0, then the background is set
to 255 and vice versaprivate boolean build(int xx, int yy, MTBImageByte skelImg, MTBNeuriteSkelGraphNode<Point2D.Double> parentNode)
xx
- point coordinate in x-directionyy
- point coordinate in y-directionskelImg
- the binary skeleton imageparentNode
- parent node of the current pointprivate void correctDirectness(MTBNeuriteSkelGraphNode<Point2D.Double> rootNode)
public void getAllPixels(Vector<Point2D.Double> pixels)
Get all pixels of the neurite skeleton graph from the nodes and edges. Pixel collection starts at the start node of the skeleton graph. WARNING!!! The specific order within the list depends on the edge direction between the single nodes. Order of the single edges depends on the build process.
pixels
- empty list to be filledprivate void getAllPixels(Vector<Point2D.Double> pixels, MTBNeuriteSkelGraphNode<Point2D.Double> tmpNode)
Get all pixels of the neurite skeleton graph from the nodes and edges. WARNING!!! The specific order within the list depends on the edges and their direction between the single nodes. Order of the single edges depends on the build process.
pixels
- empty list to be filledtmpNode
- current node for pixel collectionpublic Vector<Point2D.Double> getLongestPath(boolean includeSpines)
includeSpines
- public Vector<Point2D.Double> getShortestPath(boolean includeSpines)
includeSpines
- public Vector<Vector<Point2D.Double>> getSpinePaths()
public Vector<Vector<Point2D.Double>> getAllPaths(boolean includeSpines)
includeSpines
- private void getPath(Vector<Point2D.Double> p, MTBNeuriteSkelGraphNode<Point2D.Double> n)
private MTBImageByte markBranchPoints(MTBImageByte skelImg)
skelImg
- binary skeleton imagepublic MTBImageRGB toImage()
public MTBImageRGB toImage(MTBImageRGB rgbImage)
public MTBImageByte toByteImage()
public void print()
public MTBTableModel toSWC(String fileName, MTBImageByte neuronImage)
fileName
- filename for saving the SWC file, if null, file will not be savedneuronImage
- if radii for each skeleton point should be calculated, a image
must be given to calculate the distance map of the neuron region
and get radius of each skeleton point, can be nullprivate void depthFirstSearch(Vector<Point2D.Double> pixels, Vector<Integer> parents, MTBNeuriteSkelGraphNode<Point2D.Double> startNode, int label)
pixels
- empty vector where skeleton pixels will be storedparents
- empty vector where parents of each skeleton pixels will be storedstartNode
- start node for traversing graph and collect datalabel
- label for parent of start node (root)Copyright © 2010–2020 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.