def plot_samples(Ia, Ib, M, mean, prefix=''):
assert Ia.shape == Ib.shape, 'shapes must match'
for i, _ in enumerate(Ia):
crop = (Ia[i].transpose(1, 2, 0) + mean).astype(np.uint8)
warp = (Ib[i].transpose(1, 2, 0) + mean).astype(np.uint8)
theta = M[i].reshape((2, 3))
trns = cv2.warpAffine(warp, theta, crop.shape[0:2],
flags=cv2.INTER_LINEAR | cv2.WARP_INVERSE_MAP)
out = np.hstack((crop, warp, trns))
cv2.imwrite('%s_%d.png' % (prefix, i), out)
# This is slightly different from https://arxiv.org/abs/1703.05593,
# where the dataset is generated in advance and kept fixed. Here,
# we generate a new transformation every time an image is sampled.
评论列表
文章目录