I am looking for an efficient way to parallelize the computations in the two loops, since it take too much time to get the result
import numpy as np
import cv2
from utils import distort_point
img = cv2.imread('test.png')
height, width, channel = img.shape
n_width = int(width/2)
n_height = int(height/2)
dist_image = np.zeros((n_height,n_width,channel))
for i in range(height):
for j in range(width):
point = distort_point((j,i))
x,y = point[0],point[1]
if x <0:
x = 0
if y <0:
y = 0
if x>n_width-1:
x = n_width-1
if y>n_height-1:
y = n_height-1
dist_image[y,x,:] = img[i,j,:]
cv2.imwrite('out_test.jpg',dist_image)
basically, the distort_point function takes a pixel coordinates and map it to another coordinates using some math computations. set the output to the image boundaries if it's outside the limits, then move the pixel value to the new position (in another image)