def scaled_up_roi(roi, scale: int, shape=None):
    """
    Compute ROI for a scaled up image.

    Given a crop region in the original image compute equivalent crop in the upsampled image.

    :param roi: ROI in the original image
    :param scale: integer scale to get scaled up image
    :return: ROI in the scaled upimage
    """
    roi = tuple(slice(s.start * scale, s.stop * scale) for s in roi)
    if shape is not None:
        roi = tuple(
            slice(min(dim, s.start), min(dim, s.stop)) for s, dim in zip(roi, shape)
        )
    return roi