Object Recognition through EF + MMS

 1 from homeroberto.max_tree_alpha import MaxTreeAlpha
 2 from homeroberto.max_tree_toolbox import evsFilter
 3 from homeroberto.rob_max_tree import SSIMIndex
 4 import numpy as np
 5 
 6 img = adreadgray('homeroberto/rob_icpr_evs_simplification/objects.jpeg')
 7 adshow(img,'Original Image')
 8 
 9 mxt = MaxTreeAlpha(mmneg(img))
10 print 'Original Max-tree:'
11 print 'Nb. of nodes:', mxt.node_array.shape[0]
12 print 'Nleaves:', (mxt.node_array[:,1] == 0).sum()
13 n = 20
14 V = mxt.computeVolume()
15 Vext = mxt.getExtinctionValues(V,"volume")
16 mxt = evsFilter(mxt,Vext,n)
17 img_ef = mmneg(mxt.getImage())
18 print 'Max-tree after the Extinction Filter:'
19 print 'Nb. of nodes:', mxt.node_array.shape[0]
20 print 'Nleaves:', (mxt.node_array[:,1] == 0).sum()
21 print 'SSIM index:', SSIMIndex(img,img_ef)
22 adshow(img_ef, 'Image after the Extinction Filter')
23 sb = mxt.getSubBranches()
24 sm = mxt.getStabilityMeasure()
25 mxt = mxt.mmsMSER(sb,sm)
26 img_mms= mmneg(mxt.getImage())
27 print 'Max-Tree after EF + MMS-MSER:'
28 print 'Nb. of nodes:', mxt.node_array.shape[0]
29 print 'Nleaves:', (mxt.node_array[:,1] == 0).sum()
30 print 'SSIM index:', SSIMIndex(img,img_mms)
31 adshow(img_mms, 'Image after the EF + MMS-MSER')
32 
33 leaf_nodes = np.where(mxt.node_array[:,1] == 0)[0]
34 bin_img = mxt.recLevelComponent(leaf_nodes[0])
35 
36 for node in leaf_nodes[1:]:
37    bin_img = np.logical_or(bin_img,mxt.recLevelComponent(node))
38 
39 adshow(bin_img)
Original Max-tree:
Nb. of nodes: 12627
Nleaves: 2949
Max-tree after the Extinction Filter:
Nb. of nodes: 2614
Nleaves: 20
SSIM index: 0.930849536003
Max-Tree after EF + MMS-MSER:
Nb. of nodes: 36
Nleaves: 20
SSIM index: 0.685396007851

Original Image

Image after the Extinction Filter

Image after the EF + MMS-MSER

1 mmgraphviz(mxt.generateCCGraph(parent_scale = False))
/media/_xsb/code/object_recogintion_ef_mms/GRVIZ62539_001.png