cnn-registration icon indicating copy to clipboard operation
cnn-registration copied to clipboard

how to draw the matches just like done in the paper?

Open chuanzhidong opened this issue 6 years ago • 3 comments

how to draw the matches just like done in the paper?

chuanzhidong avatar Jun 17 '19 23:06 chuanzhidong

Hello, did you ever receive an answer?

AlphonsG avatar Jan 09 '20 11:01 AlphonsG

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

AlphonsG avatar Jan 11 '20 06:01 AlphonsG

...
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) 

RutenburgIG avatar Feb 20 '20 09:02 RutenburgIG