Text Location - Dual Processing

MainPage

Processing the image

 1 from max_tree_alpha import MaxTreeAlpha
 2 import numpy as np
 3 from morph import*
 4 
 5 
 6 
 7 img = adreadgray('Attachments/iamxt/MainPage/text.png')
 8 
 9 n = 0.0050
10 Bc = np.ones((3,3), dtype = bool)
11 mxt = MaxTreeAlpha(img,Bc)
12 
13 nleaves = (mxt.node_array[1,:] == 0).sum()
14 print 'Nb of nodes:', mxt.node_array.shape[1]
15 print 'Nb of levaes (regional maxima):', nleaves
16 nnodes = mxt.node_array.shape[1]
17 l,c = img.shape
18 adshow(img,'Original Image: shape %d x %d, nnodes = %d, nleaves = %d'%(l,c,nnodes,nleaves))
19 
20 V = mxt.computeVolume()
21 ext = mxt.computeExtinctionValues(V,"volume")
22 mxt.extinctionFilter(ext,int(n*nleaves))
23 nnodes = mxt.node_array.shape[1]
24 print 'Nb of nodes after EF:', nnodes
25 evs_img = mxt.getImage()
26 adshow(evs_img,'Filtered Image: n = %f, nnodes = %d'%(n,nnodes))
27 
28 
29 mxt.mmsT(t =0.5)
30 print 'Nb of nodes after MMS:', mxt.node_array.shape[0]
31 mms_img = mxt.getImage()
32 adshow(mms_img,'Filtered Image:  nnodes = %d'%(mxt.node_array.shape[1]))
Nb of nodes: 13054
Nb of levaes (regional maxima): 8249
Nb of nodes after EF: 2419
Nb of nodes after MMS: 10

Original Image: shape 384 x 512, nnodes = 13054, nleaves = 8249

Filtered Image: n = 0.005000, nnodes = 2419

Filtered Image: nnodes = 76

1 graph = mxt.generateCCGraph(s = (100,100), parent_scale = False, LR = True)
2 mmgraphviz(graph,title='Max-Tree after MMS')
/media/_xsb/iamxt/text_location_dual_processing/GRVIZ76243_001.png

Max-Tree after MMS

Processing the negative of the image

 1 n = 0.0050
 2 
 3 mxt = MaxTreeAlpha(mmneg(img),Bc)
 4 nleaves = (mxt.node_array[1,:] == 0).sum()
 5 nnodes = mxt.node_array.shape[1]
 6 print 'Nb of nodes:', nnodes
 7 print 'Nb of levaes (regional maxima):', nleaves
 8 l,c = img.shape
 9 adshow(img,'Original Image: shape %d x %d, nnodes = %d, nleaves = %d'%(l,c,nnodes,nleaves))
10 
11 V = mxt.computeVolume()
12 ext = mxt.computeExtinctionValues(V,"volume")
13 mxt.extinctionFilter(ext,int(n*nleaves))
14 nnodes = mxt.node_array.shape[1]
15 print 'Nb of nodes after EF:', nnodes
16 
17 evs_img = mmneg(mxt.getImage())
18 adshow(evs_img,'Filtered Image: n = %f, nnodes = %d'%(n,nnodes))
19 
20 mxt.mmsT(t = 0.5)
21 
22 mms_img = mmneg(mxt.getImage())
23 adshow(mms_img,'Filtered Image: nnodes = %d'%(mxt.node_array.shape[1]))
24 print 'Nb of nodes after MMS:', mxt.node_array.shape[1]
Nb of nodes: 13144
Nb of levaes (regional maxima): 8416
Nb of nodes after EF: 1922
Nb of nodes after MMS: 75

Original Image: shape 384 x 512, nnodes = 13144, nleaves = 8416

Filtered Image: n = 0.005000, nnodes = 1922

Filtered Image: nnodes = 75

1 graph = mxt.generateCCGraph(s = (100,100), parent_scale = False, LR = True)
2 mmgraphviz(graph,title='Max-Tree after MMS')
/media/_xsb/iamxt/text_location_dual_processing/GRVIZ76243_002.png

Max-Tree after MMS