I am trying to overlay precisely one image patch to a larger patch of the image I have the coordinates where I'd like to put the patch and overlay the image but I don't know how to do with matplotlib.
I know it's possible with PILLOW (as explained here)but since I am using matplotlib for everything I'd be happy to stick to it.
For this example it would be moving the 'red patch' into the rectangle where 'it's supposed' to be.
Here is the code that I used for that:
temp_k = img_arr[0][
np.min(kernel[:, 1]) : np.max(kernel[:, 1]),
np.min(kernel[:, 0]) : np.max(kernel[:, 0]),
]
temp_w = img_arr[1][
np.min(window[:, 1]) : np.max(window[:, 1]),
np.min(window[:, 0]) : np.max(window[:, 0]),
]
w, h = temp_k.shape[::-1]
res = cv2.matchTemplate(temp_w, temp_k, cv2.TM_CCORR_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
cv2.rectangle(temp_w, top_left, bottom_right, 255, 1)
plt.imshow(temp_w, cmap="bone")
plt.imshow(temp_k, cmap="magma", alpha=0.6)
plt.plot(max_loc[0], max_loc[1], "yo")
plt.savefig("../images/test.png")
plt.tight_layout()
Does anyone has an idea how to do that ?
Thanks in advance.

