def compute_scissor(window_width, window_height, image_width, image_height,
    aspect_ratio):
    """
    Used on vtkCamera when you are trying to set the viewport to only render
    to a part of the total window size. For example, this occurs when you
    have calibrated a video camera using OpenCV, on images of 1920 x 1080,
    and then you are displaying in a VTK window that is twice as wide/high.

    This was implemented in:
    `NifTK <https://cmiclab.cs.ucl.ac.uk/CMIC/NifTK/blob/master/MITK/Modules/Core/Rendering/vtkOpenGLMatrixDrivenCamera.cxx#L129>`_.

    and it appears it should also be available in:
    `VTK <https://gitlab.kitware.com/vtk/vtk/merge_requests/882>`_.

    :param window_width: in pixels
    :param window_height: in pixels
    :param image_width: in pixels
    :param image_height: in pixels
    :param aspect_ratio: relative physical size of pixels, as x/y.
    :return: scissor_x, scissor_y, scissor_width, scissor_height in pixels
    """
    width_scale = window_width / image_width
    height_scale = window_height / (image_height / aspect_ratio)
    vpw = window_width
    vph = window_height
    if width_scale < height_scale:
        vph = int(image_height / aspect_ratio * width_scale)
    else:
        vpw = int(image_width * height_scale)
    vpx = int(window_width / 2.0 - vpw / 2.0)
    vpy = int(window_height / 2.0 - vph / 2.0)
    return vpx, vpy, vpw, vph
