getBifAncestor

MainPage

Description: This method returns the first ancestor of node that comes after a bifurcation.

Signature: bif_ancestor = MorphTreeAlpha.getBifAncestor(node)

Input:
  • node, int, node, of which the first ancestor node that bifurcates will be returned.

Output:

  • bif_ancestor, int. First ancestor node that comes after a bifurcation.

C++ Aux Function

OK
OK [C/C++ extension is up-to-date]

Python Aux Function

Python Implementation

1 def getBifAncestor(self, node):
2   return self.get_bif_ancestor_aux(node, self.node_array[0,:],self.node_array[1,:])

Example 01

 1 from morph_tree_alpha import MorphTreeAlpha
 2 import numpy as np
 3 
 4 img = np.array([[100, 100, 100, 0,   0,   0,   0,   0],\
 5                 [150, 150, 150, 150, 150, 150, 150, 150],\
 6                 [150, 160, 190, 150, 200, 200, 229, 150], \
 7                 [150, 185, 255, 150, 200, 230, 200, 150],\
 8                 [150, 180, 200, 150, 215, 229, 200, 150],\
 9                 [150, 150, 150, 150, 150, 150, 150, 150],\
10                 [50,  50,  0,   0,   0,   0,   0,   0]], dtype = np.uint8)
11 
12 
13 Bc = np.array([[0,1,0],\
14                [1,1,1],\
15                [0,1,0]], dtype = bool)
16 
17 
18 morph_tree = MorphTreeAlpha(img,Bc)
19 
20 
21 for i in xrange(morph_tree.node_array.shape[1]):
22   print "Bifurcation Ancestor of node %d:" %i
23   print morph_tree.getBifAncestor(i)
24   print
25 
26 
27 g= morph_tree.generateGraph()
28 mmgraphviz(g, title='Morph-tree')
Bifurcation Ancestor of node 0:
0

Bifurcation Ancestor of node 1:
0

Bifurcation Ancestor of node 2:
0

Bifurcation Ancestor of node 3:
0

Bifurcation Ancestor of node 4:
4

Bifurcation Ancestor of node 5:
5

Bifurcation Ancestor of node 6:
5

Bifurcation Ancestor of node 7:
5

Bifurcation Ancestor of node 8:
5

Bifurcation Ancestor of node 9:
5

Bifurcation Ancestor of node 10:
5

Bifurcation Ancestor of node 11:
11

Bifurcation Ancestor of node 12:
12

Bifurcation Ancestor of node 13:
11

Bifurcation Ancestor of node 14:
11
/media/_xsb/iamxt/morph_tree_get_bif_ancestor/GRVIZ92559_001.png

Morph-tree