当前位置:网站首页>Opencv图像缩放和平移
Opencv图像缩放和平移
2022-08-05 10:23:00 【The code family】
- 图像缩放
缩放是对图像大小进行调整,即使图像放大或缩小。
API:
cv.resize(src,dsize,fx=0,fy=0,interpolation=cv2.INTER_LINEAR)
参数:
Src:输入图像
Dsize:绝对尺寸,直接指定调整后图像的大小
Fx,fy:相对尺寸,将dsize设置为none,然后将fx和fy设置为比例因子即可
Interpolation:插值方法,

代码展示:
Import cv2 as cv
#读取图片
Img1 = cv.imread(“ ”)
#图像缩放
#绝对尺寸
Rows,cols = img1.shape[:2]
Res = cv.resize(img1,(2*cols,2*rows),interpolation = cv.INTER_CUBIC)
#相对尺寸
Res1 = cv.resize(img1,none,fx=0.5,fy=0.5)
#图像显示
#使用opencv显示图像(不推荐)
Cv.imshow(“ orignal”,img1)
Cv.imshow(“ enlarge”,res)
Cv.imshow(“ shink”,res1)
Cv.waitKey(0)
- 图像平移
图像平移将图像按照指定方向和距离,移动到相应的位置。
API:
Cv.warpAffine(img,M,dsize)
参数:

注意:输出图像的大小,它应该是(宽度,高度)的形式。请记住,width=列数,height=行数。
示例:
边栏推荐
- 第四章:activiti RuntimeService设置获和取流程变量,及与taskService的区别,开始和完成任务时设置流程变量[通俗易懂]
- MySQL之数据视图
- Data Middle Office Construction (10): Data Security Management
- 60行从零开始自己动手写FutureTask是什么体验?
- RT-Thread记录(一、RT-Thread 版本、RT-Thread Studio开发环境 及 配合CubeMX开发快速上手)
- The JVM collection that Alibaba's top architects have summarized for many years, where can't I check it!
- Confessing in the era of digital transformation: Mai Cong Software allows enterprises to use data in the easiest way
- 阿里顶级架构师多年总结的JVM宝典,哪里不会查哪里!
- This notebook of concurrent programming knowledge points strongly recommended by Ali will be a breakthrough for you to get an offer from a big factory
- QSS 选择器
猜你喜欢

一文道清什么是SPL

皕杰报表的下拉框联动

数据中台建设(十):数据安全管理

SD NAND Flash简介!

【综合类型第 35 篇】程序员的七夕浪漫时刻

This notebook of concurrent programming knowledge points strongly recommended by Ali will be a breakthrough for you to get an offer from a big factory

The host computer develops C# language: simulates the STC serial port assistant to receive the data sent by the microcontroller

什么是 DevOps?看这一篇就够了!

我们的Web3创业项目,黄了

PCB layout must know: teach you to correctly lay out the circuit board of the op amp
随机推荐
第三章 : redis数据结构种类
FPGA:开发环境Vivado的使用
Data Middle Office Construction (10): Data Security Management
uniapp 连接ibeacon
[Translation] Chaos Net + SkyWalking: Better observability for chaos engineering
Why are RELTABLESPACE values 0 for many tables displayed in sys_class?
皕杰报表的下拉框联动
FPGA:基础入门LED灯闪烁
【Unity】【UGUI】【在屏幕上显示文本】
GCC编译的时候头文件搜索规则
Brief Analysis of WSGI Protocol
The century-old Nordic luxury home appliance brand ASKO smart wine cabinet in the three-temperature area presents the Chinese Valentine’s Day, and tastes the love of the delicacy
Go编译原理系列6(类型检查)
The founder of the DFINITY Foundation talks about the ups and downs of the bear market, and where should DeFi projects go?
SkiaSharp 之 WPF 自绘 投篮小游戏(案例版)
First Decentralized Heist?Loss of nearly 200 million US dollars: analysis of the attack on the cross-chain bridge Nomad
Can MySQL use aggregate functions without GROUP BY?
FPGA:基础入门按键控制LED灯
js劫持数组push方法
Ali's new launch: Microservices Assault Manual, all operations are written out in PDF