def __window(imd, center, hh, hw):
    """Auxiliary function for slicing the array into a window.

    If the window is too large for the image, it will be downsized.

    Parameters
    ----------
    imd : `numpy.ndarray`
        The image array to be sliced.
    center : tuple of `int`\0s
        The center of the window in a (y, x) format
    hh : `int`
        The half-height of the window
    hw : `int`
        The half-width of the window

    Returns
    -------
    window : `numpy.ndarray`
        The sliced array.
    """
    H = len(imd)
    W = len(imd[0])

    if center[0] - hh < 0:
        y1 = 0
    else:
        y1 = int(center[0]) - hh
    if center[0] + hh > H:
        y2 = H
    else:
        y2 = int(center[0]) + hh

    if int(center[1]) - hw < 0:
        x1 = 0
    else:
        x1 = int(center[1]) - hw

    if int(center[1]) + hw > W:
        x2 = W
    else:
        x2 = int(center[1]) + hw
    return imd[y1:y2, x1:x2]