def build_centering_transform(image_shape, target_shape):
"""Image cetering transform
Args:
image_shape: tuple(rows, cols), input image shape
target_shape: tuple(rows, cols), output image shape
Returns:
a centering transform instance
"""
rows, cols = image_shape
trows, tcols = target_shape
shift_x = (cols - tcols) / 2.0
shift_y = (rows - trows) / 2.0
return skimage.transform.SimilarityTransform(translation=(shift_x, shift_y))
评论列表
文章目录