getImage Comparison

01. from code.na_ni import*
02. from code.parent_s import*
03. import numpy as np
04. import time
05. import matplotlib.pyplot as plt
06. import ia636
07. import cv2
08. 
09. 
10. #number of repetitions
11. nrepetitions = 1
12. 
13. # number of image concatenations
14. nconcatenations = 4
15. 
16. #Images to be tested, all must have the same initial size
17. imgs_path = '/awmedia3/www/media/Attachments/homeroberto/maxtreeicip2015_height_test/sample_images/'
18. imgs = [ os.path.join(imgs_path,f) for f in os.listdir(imgs_path) if os.path.isfile(os.path.join(imgs_path,f)) ]*10
19. a = len(imgs)
20. 
21. 
22. Bc = np.ones((3,3), dtype = bool) # structuring element
23. 
24. speed_up =  np.zeros(a, dtype = np.float)
25. 
26. for (kk,img_name) in enumerate(imgs):
27.     img = adreadgray(img_name)
28.     mxt = MaxTreeICIP2015(img,Bc)
29.     t = time.time()
30.     out = mxt.getImage2()
31.     t = time.time() -t
32.     del out
33. 
34.     t1 = time.time()
35.     out2 = mxt.getImage()
36.     t1 = time.time() - t1
37.     del out2
38. 
39.     speed_up[kk] = t1/t
40. 
41. print "Avereage speed-up:", speed_up.mean()
Avereage speed-up: 11.4313950923