Object Recognition

MainPage

 1 from max_tree_alpha import MaxTreeAlpha
 2 import numpy as np
 3 
 4 img = adreadgray('Attachments/iamxt/MainPage/objects.png')
 5 adshow(img,'Original Image')
 6 
 7 Bc = np.ones((3,3), dtype = bool)
 8 mxt = MaxTreeAlpha(mmneg(img),Bc)
 9 print 'Original Max-tree:'
10 print 'Nb. of nodes:', mxt.node_array.shape[0]
11 print 'Nleaves:', (mxt.node_array[1,:] == 0).sum()
12 n = 20
13 V = mxt.computeVolume()
14 Vext = mxt.computeExtinctionValues(V,"volume")
15 mxt.extinctionFilter(Vext,n)
16 img_ef = mmneg(mxt.getImage())
17 print 'Max-tree after the Extinction Filter:'
18 print 'Nb. of nodes:', mxt.node_array.shape[1]
19 print 'Nleaves:', (mxt.node_array[1,:] == 0).sum()
20 
21 adshow(img_ef, 'Image after the Extinction Filter')
22 
23 sm = mxt.computeStabilityMeasure()
24 mxt.mmsMSER(sm)
25 
26 img_mms= mmneg(mxt.getImage())
27 print 'Max-Tree after EF + MMS-MSER:'
28 print 'Nb. of nodes:', mxt.node_array.shape[1]
29 print 'Nleaves:', (mxt.node_array[1,:] == 0).sum()
30 adshow(img_mms, 'Image after the EF + MMS-MSER')
31 
32 leaf_nodes = where(mxt.node_array[1,:] == 0)[0]
33 bin_img = mxt.recConnectedComponent(leaf_nodes[0])
34 
35 for node in leaf_nodes[1:]:
36    bin_img = np.logical_or(bin_img,mxt.recConnectedComponent(node))
37 
38 adshow(bin_img)
Original Max-tree:
Nb. of nodes: 10
Nleaves: 2949
Max-tree after the Extinction Filter:
Nb. of nodes: 2614
Nleaves: 20
Max-Tree after EF + MMS-MSER:
Nb. of nodes: 36
Nleaves: 20

Original Image

Image after the Extinction Filter

Image after the EF + MMS-MSER

1 mmgraphviz(mxt.generateCCGraph(parent_scale = False))
/media/_xsb/iamxt/objects_recognition/GRVIZ76322_001.png