Python opencv resize函数使用

def resize(src, dsize, dst=None, fx=None, fy=None, interpolation=None): # real signature unknown; restored from __doc__
    """
    resize(src, dsize[, dst[, fx[, fy[, interpolation]]]]) -> dst
    .   @brief Resizes an image.
    .   
    .   The function resize resizes the image src down to or up to the specified size. Note that the
    .   initial dst type or size are not taken into account. Instead, the size and type are derived from
    .   the `src`,`dsize`,`fx`, and `fy`. If you want to resize src so that it fits the pre-created dst,
    .   you may call the function as follows:
    .   @code
    .   // explicitly specify dsize=dst.size(); fx and fy will be computed from that.
    .   resize(src, dst, dst.size(), 0, 0, interpolation);
    .   @endcode
    .   If you want to decimate the image by factor of 2 in each direction, you can call the function this
    .   way:
    .   @code
    .   // specify fx and fy and let the function compute the destination image size.
    .   resize(src, dst, Size(), 0.5, 0.5, interpolation);
    .   @endcode
    .   To shrink an image, it will generally look best with cv::INTER_AREA interpolation, whereas to
    .   enlarge an image, it will generally look best with cv::INTER_CUBIC (slow) or cv::INTER_LINEAR
    .   (faster but still looks OK).
    .   
    .   @param src input image.
    .   @param dst output 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.
    .   @param dsize output image size; if it equals zero, it is computed as:
    .   \f[\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}\f]
    .   Either dsize or both fx and fy must be non-zero.
    .   @param fx scale factor along the horizontal axis; when it equals 0, it is computed as
    .   \f[\texttt{(double)dsize.width/src.cols}\f]
    .   @param fy scale factor along the vertical axis; when it equals 0, it is computed as
    .   \f[\texttt{(double)dsize.height/src.rows}\f]
    .   @param interpolation interpolation method, see cv::InterpolationFlags
    .   
    .   @sa  warpAffine, warpPerspective, remap
    """
    pass

图像尺寸变换 cv2.resize()

  • cv2.resize(src, dsize[, dst[, fx[, fy[, interpolation]]]]) → dst
interpolation选项 所用的插值方法
INTER_NEAREST最近邻插值
INTER_LINEAR双线性插值(默认设置)
INTER_AREA使用像素区域关系进行重采样。
它可能是图像抽取的首选方法,因为它会产生无云纹理的结果。
但是当图像缩放时,它类似于INTER_NEAREST方法。
INTER_CUBIC4x4像素邻域的双三次插值
INTER_LANCZOS48x8像素邻域的Lanczos插值


eg:

or_pic =cv2.imread(image_path)
change_image_size=cv2.resize(or_pic,(600,600),interpolation=cv2.INTER_AREA)

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值