getImage

MainPage

Description: This method returns the image corresponding to the tree.

Signature: img = MorphTreeAlpha.getChildren()

Input:

Output:

  • img, 2d-array, uint8. Array of the image corresponding to the tree.

C++ Aux Function

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

Python Aux Function

Python Implementation

1 def getImage(self):
2     """
3     This method returns the image corresponding to the tree.
4     """
5     out_img = np.empty(self.node_index.shape, dtype = np.uint16)
6     self.get_image_aux(self.node_array[2],self.node_index,out_img)
7     return out_img.astype(self.ftype)

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 img2 = morph_tree.getImage()
22 
23 print 'img = morph_tree.getImage():'
24 print (img == img2).all()
25 
26 g= morph_tree.generateGraph()
27 mmgraphviz(g, title='Morph-tree')
img = morph_tree.getImage():
True
/media/_xsb/iamxt/morph_tree_get_image/GRVIZ13853_001.png

Morph-tree