def crop_center(img, img_wh):
    """
    Crop box of size img_wh from center of image.
    assumes box is smaller than image.

    :parameters:
        - `img`: Input Image
        - `img_wh`: Desired width, height

    >>> img = Image.new('L', (128, 128))
    >>> imgc = crop_center(img, (50, 50))
    >>> imgc.size
    (50, 50)
    """
    w, h = img_wh
    if w > img.size[0] or h > img.size[1]:
        raise ValueError('crop dimensions larger than image')
    size = w, h
    col0 = (img.size[0] - size[0]) // 2
    row0 = (img.size[1] - size[1]) // 2
    box = col0, row0, col0 + size[0], row0 + size[1]
    return img.crop(box)
