python - Autojit - how to increase performance for rotating -
i have next code:
def rotation_cpu(img, theta, dst): costheta = np.cos(theta) sintheta = np.sin(theta) in range(512): j in range(512): xpos = costheta * - sintheta * j ypos = sintheta * + costheta * j dst[xpos + 725/2, ypos ] = img[i,j]
i'm testing it, , 1.7300620079
seconds. but, when utilize @autojit
decorator worse.
from numbapro import autojit @autojit def rotation_cpu(img, theta, dst): costheta = np.cos(theta) sintheta = np.sin(theta) in range(512): j in range(512): xpos = costheta * - sintheta * j ypos = sintheta * + costheta * j dst[xpos + 725/2, ypos ] = img[i,j]
with 1.92721390724
seconds. should alter improve performances?
the code testing is:
from timeit import default_timer timer scipy.misc import imread img = imread("pic.jpg") # 512x512 pic. theta = 45 ts = timer() dst = np.zeros((725, 725)) # new boundaries rotation_cpu(img, theta * np.pi / 180, dst) te = timer() print te - ts
python anaconda numba numba-pro
No comments:
Post a Comment