天天看点

cv2.resize与PIL中resize的区别PIL.Image.resize

PIL.Image.resize

Image.resize(size, resample=0)[source]
'''
Returns a resized copy of this image.
参数:	
size – The requested size in pixels, as a 2-tuple: (width, height).
resample – An optional resampling filter. This can be one of PIL.Image.NEAREST (use nearest neighbour), PIL.Image.BILINEAR (linear interpolation in a 2x2 environment), PIL.Image.BICUBIC (cubic spline interpolation in a 4x4 environment), or PIL.Image.ANTIALIAS (a high-quality downsampling filter). If omitted, or if the image has mode “1” or “P”, it is set PIL.Image.NEAREST.
返回:	
An Image object.
'''
           

其默认的插值方式为

最近邻

cv2.resize(src, dsize[, dst[, fx[, fy[, interpolation]]]]) → dst
'''
Parameters:	
src – Source image.
dst – Destination image. It has the size dsize (when it is non-zero) or the size computed from src.size() , fx , and fy . The type of dst is the same as of src .
dsize –
Destination image size. If it is zero, it is computed as:

\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}

Either dsize or both fx and fy must be non-zero.

fx –
Scale factor along the horizontal axis. When it is 0, it is computed as

\texttt{(double)dsize.width/src.cols}

fy –
Scale factor along the vertical axis. When it is 0, it is computed as

\texttt{(double)dsize.height/src.rows}

interpolation –
Interpolation method:

INTER_NEAREST - a nearest-neighbor interpolation
INTER_LINEAR - a bilinear interpolation (used by default)
INTER_AREA - resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire’-free results. But when the image is zoomed, it is similar to the INTER_NEAREST method.
INTER_CUBIC - a bicubic interpolation over 4x4 pixel neighborhood
INTER_LANCZOS4 - a Lanczos interpolation over 8x8 pixel neighborhood
'''
           

其默认的插值方式为

双线性插值