python 几何教学_opencv-python-学习笔记九(图像几何转换)

本文详细介绍了OpenCV-Python中用于图像几何转换的函数,包括缩放、平移、旋转、仿射变换和透视变换。通过示例代码展示了如何使用`cv.resize()`进行缩放,`cv.warpAffine()`进行平移和旋转,以及如何通过`cv.getAffineTransform()`和`cv.getPerspectiveTransform()`实现仿射和透视变换。
摘要由CSDN通过智能技术生成

opencv提供了2个转换函数,可以对图像进行任意转换。

cv.warpAffine和cv.warpPerspective.第一种采取2*3的矩阵作为输入。第二种采取3*3的矩阵作为输入。

1.缩放

函数:

cv.resize(src, dsize[, dst[, fx[, fy[, interpolation]]]])

参数:

src:输入图像

dsize:目标尺寸,整形,非0

dst:目标图像,大小为dsize,或由src.size()计算而来

fx:水平轴缩放比例,非0

fy:垂直轴缩放比例,非0

interpolation:插值算法,分为以下几种

INTER_NEAREST

Python: cv.INTER_NEAREST

nearest neighbor interpolation最邻近插值

INTER_LINEAR

Python: cv.INTER_LINEAR

bilinear interpolation双线性插值

INTER_CUBIC

Python: cv.INTER_CUBIC

bicubic interpolation双三次插值

INTER_AREA

Python: cv.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_LANCZOS4

Python: cv.INTER_LANCZOS4

Lanczos interpolation over 8x8 neighborhood.基于8x8像素邻域的Lanczos插值

INTER_LINEAR_EXACT

Python: cv.INTER_LINEAR_EXACT

Bit exact bilinear interpolation.位精确双线性插值

INTER_MAX

Python: cv.INTER_MAX

mask for interpolation codes.插补码掩码

WARP_FILL_OUTLIERS

Python: cv.WARP_FILL_OUTLIERS

flag, fills all of the destination image pixels. If some of them correspond to outliers in the source image, they are set to zero

WARP_INVERSE_MAP

Python: cv.WARP_INVERSE_MAP

flag, inverse transformation

For example, linear

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值