I am working on a project, matching image fragments to larger pieces. For example, matching Fragment to Complete in the below image.
Following on from this question, I am trying to draw a lines across two plots to indicate matching points, with each point having different coordinates.
This is the code that I have:
import matplotlib.pyplot as plt
from matplotlib.patches import ConnectionPatch
import numpy as np
(x1,y1) = (292, 21)
(x2,y2) = (930, 1111)
fig = plt.figure()
a1=fig.add_subplot(1,2,1)
imgplot = plt.imshow(fragment) #fragment is the name of the first image
a2=fig.add_subplot(1,2,2)
imgplot = plt.imshow(complete) #complete is the name of the second image
xy1 = (x1,y1)
xy2 = (x2,y2)
con = ConnectionPatch(xyA=xy1, xyB=xy2, coordsA="data", coordsB="data",
axesA=a1, axesB=a2, color="red")
a1.add_artist(con)
a1.plot(x1,y1,'ro',markersize=2)
a2.plot(x2,y2,'ro',markersize=2)
plt.show()
However, the resulting image comes out with the line going behind the second image (as per below). What do I need to change in my code?
NB: I realise I could be doing this with OpenCV.