(img, size, interpolation=PIL.Image.BILINEAR)
Resize image to match the given shape.

    The backend used by :func:`resize` is configured by
    :obj:`chainer.global_config.cv_resize_backend`.
    Two backends are supported: "cv2" and "PIL".
    If this is :obj:`None`, "cv2" is used whenever "cv2" is installed,
    and "PIL" is used when "cv2" is not installed.

    Args:
        img (~numpy.ndarray): An array to be transformed.
            This is in CHW format and the type should be :obj:`numpy.float32`.
        size (tuple): This is a tuple of length 2. Its elements are
            ordered as (height, width).
        interpolation (int): Determines sampling strategy. This is one of
            :obj:`PIL.Image.NEAREST`, :obj:`PIL.Image.BILINEAR`,
            :obj:`PIL.Image.BICUBIC`, :obj:`PIL.Image.LANCZOS`.
            Bilinear interpolation is the default strategy.

    Returns:
        ~numpy.ndarray: A resize array in CHW format.
Resize image to match the given shape.
Resize image to match the given shape .
def resize(img, size, interpolation=PIL.Image.BILINEAR):
    """Resize image to match the given shape.

    The backend used by :func:`resize` is configured by
    :obj:`chainer.global_config.cv_resize_backend`.
    Two backends are supported: "cv2" and "PIL".
    If this is :obj:`None`, "cv2" is used whenever "cv2" is installed,
    and "PIL" is used when "cv2" is not installed.

    Args:
        img (~numpy.ndarray): An array to be transformed.
            This is in CHW format and the type should be :obj:`numpy.float32`.
        size (tuple): This is a tuple of length 2. Its elements are
            ordered as (height, width).
        interpolation (int): Determines sampling strategy. This is one of
            :obj:`PIL.Image.NEAREST`, :obj:`PIL.Image.BILINEAR`,
            :obj:`PIL.Image.BICUBIC`, :obj:`PIL.Image.LANCZOS`.
            Bilinear interpolation is the default strategy.

    Returns:
        ~numpy.ndarray: A resize array in CHW format.

    """
    if len(img) == 0:
        assert len(size) == 2
        return np.empty((0,) + size, dtype=img.dtype)

    if chainer.config.cv_resize_backend is None:
        if _cv2_available:
            return _resize_cv2(img, size, interpolation)
        else:
            return _resize_pil(img, size, interpolation)
    elif chainer.config.cv_resize_backend == 'cv2':
        if not _cv2_available:
            raise ValueError('cv2 is not installed even though '
                             'chainer.config.cv_resize_backend == \'cv2\'')
        return _resize_cv2(img, size, interpolation)
    elif chainer.config.cv_resize_backend == 'PIL':
        return _resize_pil(img, size, interpolation)
    else:
        raise ValueError('chainer.config.cv_resize_backend must be one of:'
                         '[\'cv2\', \'PIL\']')
def resize ( img , size , interpolation = PIL . Image . BILINEAR ) : if len ( img ) == 0 : assert len ( size ) == 2 return np . empty ( ( 0 , ) + size , dtype = img . dtype ) if chainer . config . cv_resize_backend is None : if _cv2_available : return _resize_cv2 ( img , size , interpolation ) else : return _resize_pil ( img , size , interpolation ) elif chainer . config . cv_resize_backend == 'cv2' : if not _cv2_available : raise ValueError ( 'cv2 is not installed even though ' 'chainer.config.cv_resize_backend == \'cv2\'' ) return _resize_cv2 ( img , size , interpolation ) elif chainer . config . cv_resize_backend == 'PIL' : return _resize_pil ( img , size , interpolation ) else : raise ValueError ( 'chainer.config.cv_resize_backend must be one of:' '[\'cv2\', \'PIL\']' )