def crop_transform(img, params):
# take the center crop of the original image as I_{A}
crop = center_crop(img, 227)
M, = generate_transformations(
1, (img.shape[0], img.shape[1]), **params
)
# apply T_{\theta_{GT}} to I_{A} to get I_{B}
warp = cv2.warpAffine(
crop.astype(np.float32), M[:2], (crop.shape[1], crop.shape[0]),
flags=cv2.INTER_LINEAR, borderMode=cv2.BORDER_REFLECT_101
)
return crop, warp, M
评论列表
文章目录