def build_center_uncenter_transforms(image_shape):
"""Center Unceter transform
These are used to ensure that zooming and rotation happens around the center of the image.
Use these transforms to center and uncenter the image around such a transform.
Args:
image_shape: tuple(rows, cols), input image shape
Returns:
a center and an uncenter transform instance
"""
center_shift = np.array(
[image_shape[1], image_shape[0]]) / 2.0 - 0.5 # need to swap rows and cols here apparently! confusing!
tform_uncenter = skimage.transform.SimilarityTransform(
translation=-center_shift)
tform_center = skimage.transform.SimilarityTransform(
translation=center_shift)
return tform_center, tform_uncenter
评论列表
文章目录