def resize(image, w, h, **kwargs):
"""
Resize image.
Image can be up- or down-sized (using interpolation). For details see:
http://scikit-image.org/docs/dev/api/skimage.transform.html#skimage.transform.resize
>>> image = np.ones((10,5), dtype='uint8')
>>> resize(image, 4, 3)
array([[1, 1, 1, 1],
[1, 1, 1, 1],
[1, 1, 1, 1]], dtype=uint8)
:param numpy array image: Numpy array with range [0,255] and dtype 'uint8'.
:param int w: Width in pixels.
:param int h: Height in pixels.
:param kwargs kwargs: Keyword arguments for the underlying scikit-image
resize function, e.g. order=1 for linear interpolation.
:return: Resized image
:rtype: numpy array with range [0,255] and dtype 'uint8'
"""
set_default_order(kwargs)
return skt.resize(image, (h, w), mode='constant',
preserve_range=True, **kwargs).astype('uint8')
评论列表
文章目录