0

I'm trying to map pixels values from one image to another on the gpu with Python cupyx.scipy.ndimage map_coordinates function. The output cupy-array is all zeros. When I'm using scipy.ndimage to run its map_coordinates I'm getting the interpolated array. Why does it happen and how to fix it?

the piece of code relevant to the question:

tform = PiecewiseAffineTransform()
tform.estimate(match_p_src, match_p_dst)
warp_coor = warp_coords(tform.inverse, (n_rows, n_cols))
dst_cols = np.reshape(warp_coor[0], (n_rows*n_cols, 1))
dst_rows = np.reshape(warp_coor[1], (n_rows*n_cols, 1))

image_warp = scipy.ndimage.map_coordinates(image, [dst_cols, dst_rows])
image_warp = np.reshape(image_warp, (n_rows, n_cols))

d_image = cp.asanyarray(image)
d_image_warp = cp.ndarray((n_rows*n_cols, 1), dtype=cp.uint16)
cupyx.scipy.ndimage.map_coordinates(d_image, cp.asanyarray([dst_cols, dst_rows]), output=d_image_warp)
d_image_warp = cp.reshape(d_image_warp, (n_rows, n_cols))

Thank you!

rotemp
  • 11
  • 1

1 Answers1

1

O.K, I found the problem. Although the documentation states that the default value of the interpolation order is one, it's actually None. By changing the order argument to zero or one the interpolation works fine.

rotemp
  • 11
  • 1