Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import time
- # -----
- def combine_planes(img):
- tmp_img = img.astype('int32')
- b,g,r = tmp_img[:,:,0], tmp_img[:,:,1], tmp_img[:,:,2]
- combo = b + g * (2**8) + r * (2**16)
- return combo
- # -----
- test_image = (np.random.rand(1080,1920,3) * 255).astype('uint8')
- deltas = [0.0, 0.0, 0.0, 0.0]
- ITER_COUNT = 5
- for i in range(ITER_COUNT):
- t1 = time.time()
- im=test_image.reshape(1,-1,3)
- t2 = time.time()
- im = combine_planes(im)
- t3 = time.time()
- im_list=im.tolist()
- t4 = time.time()
- im_set=set(im_list[0])
- t5 = time.time()
- deltas[0] += t2 - t1
- deltas[1] += t3 - t2
- deltas[2] += t4 - t3
- deltas[3] += t5 - t4
- deltas[:] = [n / ITER_COUNT for n in deltas]
- print deltas
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement