cnn-registration
cnn-registration copied to clipboard
how to draw the matches just like done in the paper?
how to draw the matches just like done in the paper?
Hello, did you ever receive an answer?
how to draw the matches just like done in the paper?
I think I figured it out. Insert the code below in the demo.py file after this line: X, Y, Z = reg.register(IX, IY) (Don't forget to import numpy as np).
matches = [[i, i] for i in range(0, len(X))]
matches = np.asarray(matches)
_, ax = plt.subplots()
plot_matches(
ax,
IX,
IY,
X,
Y,
matches,
matches_color='b')
ax.axis('off')
plt.show()
@wisemaker @studentguoyiyuan @sunbin1205
...
X, Y, Z, d1 = self.register(IX, IY)
registered = tps_warp(Y, Z, IY, IX.shape)
res = np.zeros(shape=(IX.shape[0] * 2, IX.shape[1], 3), dtype=np.uint8)
res[:IX.shape[0], :, :] = IX
res[IX.shape[0]:, :, :] = registered
for i, pnt in enumerate(X):
src_x = int(pnt[1])
src_y = int(pnt[0])
dst_x = int(Z[i][1])
dst_y = int(Z[i][0] + IX.shape[0])
cv2.line(res, (src_x, src_y), (dst_x, dst_y), (255, 0, 0), 2)
cv2.circle(res, (src_x, src_y), 5, (0, 255, 0), -1)
cv2.circle(res, (dst_x, dst_y), 5, (0, 255, 0), -1)
cv2.imwrite('res.jpg', res)