def center_crop(src, size, interp=2):
    'Crops the image `src` to the given `size` by trimming on all four\n    sides and preserving the center of the image. Upsamples if `src` is smaller\n    than `size`.\n\n    .. note:: This requires MXNet to be compiled with USE_OPENCV.\n\n    Parameters\n    ----------\n    src : NDArray\n        Binary source image data.\n    size : list or tuple of int\n        The desired output image size.\n    interp : int, optional, default=2\n        Interpolation method. See resize_short for details.\n\n    Returns\n    -------\n    NDArray\n        The cropped image.\n    Tuple\n        (x, y, width, height) where x, y are the positions of the crop in the\n        original image and width, height the dimensions of the crop.\n\n    Example\n    -------\n    >>> with open("flower.jpg", \'rb\') as fp:\n    ...     str_image = fp.read()\n    ...\n    >>> image = mx.image.imdecode(str_image)\n    >>> image\n    <NDArray 2321x3482x3 @cpu(0)>\n    >>> cropped_image, (x, y, width, height) = mx.image.center_crop(image, (1000, 500))\n    >>> cropped_image\n    <NDArray 500x1000x3 @cpu(0)>\n    >>> x, y, width, height\n    (1241, 910, 1000, 500)\n    '
    (h, w, _) = src.shape
    (new_w, new_h) = scale_down((w, h), size)
    x0 = int(((w - new_w) / 2))
    y0 = int(((h - new_h) / 2))
    out = fixed_crop(src, x0, y0, new_w, new_h, size, interp)
    return (out, (x0, y0, new_w, new_h))
Crops the image `src` to the given `size` by trimming on all four
sides and preserving the center of the image. Upsamples if `src` is smaller
than `size`.

.. note:: This requires MXNet to be compiled with USE_OPENCV.

Parameters
----------
src : NDArray
    Binary source image data.
size : list or tuple of int
    The desired output image size.
interp : int, optional, default=2
    Interpolation method. See resize_short for details.

Returns
-------
NDArray
    The cropped image.
Tuple
    (x, y, width, height) where x, y are the positions of the crop in the
    original image and width, height the dimensions of the crop.

Example
-------
>>> with open("flower.jpg", 'rb') as fp:
...     str_image = fp.read()
...
>>> image = mx.image.imdecode(str_image)
>>> image
<NDArray 2321x3482x3 @cpu(0)>
>>> cropped_image, (x, y, width, height) = mx.image.center_crop(image, (1000, 500))
>>> cropped_image
<NDArray 500x1000x3 @cpu(0)>
>>> x, y, width, height
(1241, 910, 1000, 500)
def center_crop(src, size, interp=2):
    'Crops the image `src` to the given `size` by trimming on all four\n    sides and preserving the center of the image. Upsamples if `src` is smaller\n    than `size`.\n\n    .. note:: This requires MXNet to be compiled with USE_OPENCV.\n\n    Parameters\n    ----------\n    src : NDArray\n        Binary source image data.\n    size : list or tuple of int\n        The desired output image size.\n    interp : int, optional, default=2\n        Interpolation method. See resize_short for details.\n\n    Returns\n    -------\n    NDArray\n        The cropped image.\n    Tuple\n        (x, y, width, height) where x, y are the positions of the crop in the\n        original image and width, height the dimensions of the crop.\n\n    Example\n    -------\n    >>> with open("flower.jpg", \'rb\') as fp:\n    ...     str_image = fp.read()\n    ...\n    >>> image = mx.image.imdecode(str_image)\n    >>> image\n    <NDArray 2321x3482x3 @cpu(0)>\n    >>> cropped_image, (x, y, width, height) = mx.image.center_crop(image, (1000, 500))\n    >>> cropped_image\n    <NDArray 500x1000x3 @cpu(0)>\n    >>> x, y, width, height\n    (1241, 910, 1000, 500)\n    '
    (h, w, _) = src.shape
    (new_w, new_h) = scale_down((w, h), size)
    x0 = int(((w - new_w) / 2))
    y0 = int(((h - new_h) / 2))
    out = fixed_crop(src, x0, y0, new_w, new_h, size, interp)
    return (out, (x0, y0, new_w, new_h))