getChildren

MainPage

Description: This method returns the children of node.

Signature: node_children = MorphTreeAlpha.getChildren(node)

Input:
  • node, int, node, of which its children will be returned.

Output:

  • node_children, 1d-array, int32. Array containing the children of node.

C++ Aux Function

OK
OK

--------------------------------------------------------------------------------
    Mon Aug 15 17:40:01 2016
--------------------------------------------------------------------------------
-- Configuring done
-- Generating done
-- Build files have been written to: <pkg_dir>/_build/_morph_tree_get_chilldren
[ 25%] Swig source
Scanning dependencies of target __morph_tree_get_chilldren
[ 50%] Building CXX object CMakeFiles/__morph_tree_get_chilldren.dir/_morph_tree_get_chilldrenPYTHON_wrap.o
[ 75%] Building CXX object CMakeFiles/__morph_tree_get_chilldren.dir/_morph_tree_get_chilldren.o
[100%] Building CXX object CMakeFiles/__morph_tree_get_chilldren.dir<pkg_dir>/_build/simple_arrays.o
Linking CXX shared module __morph_tree_get_chilldren.so
[100%] Built target __morph_tree_get_chilldren

Python Aux Function

Python Implementation

 1 def getChildren(self,node = 0):
 2     if not self._children_updated:
 3         self._cum_children_hist = self.node_array[1,:].cumsum().astype(np.int32)
 4         par = self.node_array[0,:]
 5         self._children_list = self.get_children_aux(self._cum_children_hist.copy(),par)
 6         self._children_updated = True
 7     if node == 0:
 8         return self._children_list[0:self._cum_children_hist[node]]
 9     else:
10         return self._children_list[self._cum_children_hist[node-1]:self._cum_children_hist[node]]

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 "Children of node %d:" %i
23   print morph_tree.getChildren(i)
24   print
25 
26 
27 g= morph_tree.generateGraph()
28 mmgraphviz(g, title='Morph-tree')
Children of node 0:
[1]

Children of node 1:
[2]

Children of node 2:
[3]

Children of node 3:
[5 4]

Children of node 4:
[12 11]

Children of node 5:
[6]

Children of node 6:
[7]

Children of node 7:
[8]

Children of node 8:
[9]

Children of node 9:
[10]

Children of node 10:
[]

Children of node 11:
[13]

Children of node 12:
[]

Children of node 13:
[14]

Children of node 14:
[]
/media/_xsb/iamxt/morph_tree_get_chilldren/GRVIZ93601_001.png

Morph-tree