Advertisement
dan-masek

Untitled

May 8th, 2016
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import numpy as np
  2. import time
  3.  
  4. # -----
  5.  
  6. def combine_planes(img):
  7. tmp_img = img.astype('int32')
  8. b,g,r = tmp_img[:,:,0], tmp_img[:,:,1], tmp_img[:,:,2]
  9. combo = b + g * (2**8) + r * (2**16)
  10. return combo
  11.  
  12. # -----
  13.  
  14. test_image = (np.random.rand(1080,1920,3) * 255).astype('uint8')
  15.  
  16. deltas = [0.0, 0.0, 0.0, 0.0]
  17.  
  18. ITER_COUNT = 5
  19.  
  20. for i in range(ITER_COUNT):
  21. t1 = time.time()
  22. im=test_image.reshape(1,-1,3)
  23. t2 = time.time()
  24. im = combine_planes(im)
  25. t3 = time.time()
  26. im_list=im.tolist()
  27. t4 = time.time()
  28. im_set=set(im_list[0])
  29. t5 = time.time()
  30. deltas[0] += t2 - t1
  31. deltas[1] += t3 - t2
  32. deltas[2] += t4 - t3
  33. deltas[3] += t5 - t4
  34.  
  35. deltas[:] = [n / ITER_COUNT for n in deltas]
  36.  
  37. print deltas
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement