def perturb_multiscale(img, scale_factors, augmentation_params, target_shapes, rng=np.random):
"""
scale is a DOWNSCALING factor.
"""
tform_center, tform_uncenter = build_center_uncenter_transforms(img.shape)
tform_augment = random_perturbation_transform(rng=rng, **augmentation_params)
tform_augment = tform_uncenter + tform_augment + tform_center # shift to center, augment, shift back (for the rotation/shearing)
output = []
for scale, target_shape in zip(scale_factors, target_shapes):
if isinstance(scale, skimage.transform.ProjectiveTransform):
tform_rescale = scale
else:
tform_rescale = build_rescale_transform(scale, img.shape, target_shape) # also does centering
output.append(fast_warp(img, tform_rescale + tform_augment, output_shape=target_shape, mode='constant').astype('float32'))
return output
评论列表
文章目录