1. import numpy as np
2. import cv2
3. from max_tree_c_01 import build_max_tree
4. from pixel_oriented_filering import compute_area, direct_filter
5. import time
6. from iamxt.max_tree_c_01 import build_max_tree
7. from iamxt.pixel_oriented_filering import compute_area, direct_filter
8. import max_tree_alpha as iamxt
01. import numpy as np
02. 
03. img = adreadgray(find_attachment_file('iamxt/MainPage/monalisa.jpg'))
04. Bc = np.ones((3,3), dtype = bool)
05. mxt = iamxt.MaxTreeAlpha(img,Bc)
06. print mxt.node_array.shape[1]
07. mxt.areaOpen(500)
08. print mxt.node_array.shape[1]
09. area = mxt.node_array[3,:]
10. parent = mxt.node_array[1,:]
11. to_keep = (area[parent]- area)*1.0/area[parent] < 0.8
12. mxt.contractDR(to_keep)
13. print "Nós mantidos:", to_keep.sum()
14. adshow(img)
15. adshow(mxt.getImage())
168813
1046
Nós mantidos: 92

01. import numpy as np
02. 
03. img = adreadgray(find_attachment_file('iamxt/MainPage/monalisa.jpg'))
04. Bc = np.ones((3,3), dtype = bool)
05. mxt = iamxt.MaxTreeAlpha(img,Bc)
06. print mxt.node_array.shape[1]
07. #mxt.areaOpen(500)
08. print mxt.node_array.shape[1]
09. H = mxt.computeHeight()
10. parent = mxt.node_array[1,:]
11. to_keep = (H - H[parent]) > 20
12. 
13. mxt.contractDR(to_keep)
14. print "Nós mantidos:", to_keep.sum()
15. adshow(img)
16. adshow(mxt.getImage())
168813
168813
Nós mantidos: 1530

01. import numpy as np
02. 
03. img = adreadgray(find_attachment_file('iamxt/MainPage/monalisa.jpg'))
04. Bc = np.ones((3,3), dtype = bool)
05. mxt = iamxt.MaxTreeAlpha(img,Bc)
06. print mxt.node_array.shape[1]
07. H = mxt.computeHeight()
08. parent = mxt.node_array[1,:]
09. to_keep = np.logical_or(((H - H[parent]) > 20),(mxt.node_array[1,:] == 0))
10. 
11. mxt.contractDR(to_keep)
12. print "Nós mantidos:", to_keep.sum()
13. adshow(img)
14. adshow(mxt.getImage())
168813
Nós mantidos: 61858