def shift_window_inside_image(start, end, image_axis_size, input_axis_size):
    """
    If the window goes outside the bound of the image, then shifts it to fit inside the image.
    """
    if start < 0:
        start = 0
        end = start + input_axis_size
    elif end > image_axis_size:
        end = image_axis_size
        start = end - input_axis_size

    return start, end