Got colored border after using cv2.remap function for undistortion

When using cv2.remap function to remap distorted 1920 * 1080 pixels image to undistorted 2912 * 1184 pixels, I have got right results, but the color of border look strange, (there are red blue, pink…), how can I get image with black borders?

Here is my operation and code:
First calculating the undistort rectify map by camera parameters and distortion coefficients, the size of the map is (4, 1184 * 2912), where 4 is x, y of target image (dst_y, dst_x), and x, y of source image (src_y, src_x), 1184*2912 is the number of pixels in target image.
Then I reshape the value of src_y, src_x to got map_y, map_x, and using cv2.remap to undistort the image:

def cv2_remap(img_src, points_map):
    map_y = points_map[2, :].reshape(1184, 2912).astype(np.float32)
    map_x = points_map[3, :].reshape(1184, 2912).astype(np.float32)
    img_dst = cv2.remap(img_src, map_x, map_y, interpolation=cv2.INTERSECT_NONE,
                        borderMode=cv2.BORDER_TRANSPARENT, borderValue=(0, 0, 0))
    return img_dst

have you looked up the border mode in the documentation?

and what’s going on with your interpolation flag?

I tried to modify the border mode, and still got the same result. But I think I found the reason. It is due to the undistort map I calculated. I added a logic that when the corresponding coordinates is beyond the size of source image, the dst_y, dst_x, src_y and src_x will be set as [0,0,0,0]. This lead to the pixels in the border of target image always get the values of (0, 0) pixel in source image. I have corrected the code and I think this issue can be closed. Thank you for your reply, best wishes!