import random


def get_perspective_params(img, distortion_scale):
    """Helper function to get parameters for RandomPerspective.
    """
    img_width, img_height = img.size
    distorted_half_width = int(img_width / 2 * distortion_scale)
    distorted_half_height = int(img_height / 2 * distortion_scale)
    top_left = (random.randint(0, distorted_half_width),
                random.randint(0, distorted_half_height))
    top_right = (random.randint(img_width - distorted_half_width - 1, img_width - 1),
                 random.randint(0, distorted_half_height))
    bottom_right = (random.randint(img_width - distorted_half_width - 1, img_width - 1),
                    random.randint(img_height - distorted_half_height - 1, img_height - 1))
    bottom_left = (random.randint(0, distorted_half_width),
                   random.randint(img_height - distorted_half_height - 1, img_height - 1))

    start_points = [(0, 0), (img_width - 1, 0), (img_width - 1, img_height - 1), (0, img_height - 1)]
    end_points = [top_left, top_right, bottom_right, bottom_left]
    return start_points, end_points