OpenCV凹凸包

本文介绍了如何使用OpenCV库进行图像的缩放、位移以及仿射和视角转换。通过示例代码展示了`cv.resize()`用于图像缩放,`cv.warpAffine()`用于位移和仿射变换,以及`cv.warpPerspective()`实现视角转换。这些变换函数都涉及到变换矩阵的使用,并详细解释了相关参数的意义。
摘要由CSDN通过智能技术生成

缩放
import numpy as np
import cv2 as cv

img = cv.imread('test.jpg')

res = cv.resize(img, None, fx=2, fy=2, interpolation=cv.INTER_CUBIC)

# OR

height, width = img.shape[:2]
res = cv.resize(img, (2*width, 2*height), interpolation=cv.INTER_CUBIC)
cv.resize(src, dsize[, dst[, fx[, fy[, interpolation]]]])
dsize:输出图片的大小,如果为None,dsize = Size(round(fx*src.cols), round(fy*src.rwos))
fx:沿x轴的比例因子,当其等于0时,fx = (double)dsize.width / src.cols
fy:沿y轴的比例因子,当其等于0时,fy = (double)dsize.height / src.rows
dsize和fx、fy不能同时为0;当dsize和fx、fy都定义时,以dsize为准
interpolation:插值方式,默认为cv.INTER_LINEAR;详见cv::InterpolationFlags

位移
import cv2 as cv
import numpy as np


img = cv.imread('opencv.jpg', 0)
rows, cols = img.shape

M =

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值