def crop_img(img, crop):
    """Extract a center crop of the input image.

    Parameters
    ----------
    img : PIL.Image.Image
        Image to be cropped.
    crop : tuple
        Dimensions of the desired crop (height, width).

    Returns
    -------
    PIL.Image
        Cropped image.

    Notes
    -----
    The image center will be computed by rounding the coordinates
    if necessary. Python round default behavior is toward the
    closest even decimal.

    """
    w, h = img.size
    if crop[1] >= w or crop[0] >= h:
        raise ValueError('crop dimensions cannot be higher than {:}'.format
            (img.size))
    x1 = int(round((w - crop[1]) / 2.0))
    y1 = int(round((h - crop[0]) / 2.0))
    return img.crop((x1, y1, x1 + crop[1], y1 + crop[0]))
