Skip to content

Instantly share code, notes, and snippets.

@sergeyprokudin
Created March 30, 2021 10:28
Show Gist options
  • Save sergeyprokudin/724f5633024040ab11a013f81c48a1c2 to your computer and use it in GitHub Desktop.
Save sergeyprokudin/724f5633024040ab11a013f81c48a1c2 to your computer and use it in GitHub Desktop.
get (u,v) coords of every image pixel
def get_img_uv_coords(img):
"""
Get u,v coords for image pixels
"""
img_height, img_width = img.shape[0], img.shape[1]
uv_map = np.zeros([img_height, img_width, 2])
u = np.arange(0, img_height)
v = np.arange(0, img_width)
us, vs = np.meshgrid(v, u)
uv_map[:, :, 1] = us
uv_map[:, :, 0] = vs
return uv_map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment