当前位置:网站首页>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=行数。
示例:
边栏推荐
- RT - Thread record (a, RT, RT Thread version - Thread Studio development environment and cooperate CubeMX quick-and-dirty)
- 5. Deploy the web project to the cloud server
- STM32+ULN2003 drives 28BYJ4 stepper motor (forward and reverse according to the number of turns)
- 【综合类型第 35 篇】程序员的七夕浪漫时刻
- 2022 Hangzhou Electric Power Multi-School Session 6 1008.Shinobu Loves Segment Tree Regular Questions
- Score interview (1)----related to business
- 【AGC】增长服务1-远程配置示例
- The query that the user's test score is greater than the average score of a single subject
- High-quality DeFi application building guide to help developers enjoy DeFi Summer
- IDEA performs the Test operation, resulting in duplicate data when data is inserted
猜你喜欢
电竞、便捷、高效、安全,盘点OriginOS功能的关键词
首次去中心化抢劫?近2亿美元损失:跨链桥Nomad 被攻击事件分析
【MindSpore易点通机器人-01】你也许见过很多知识问答机器人,但这个有点不一样
Confessing in the era of digital transformation: Mai Cong Software allows enterprises to use data in the easiest way
教你本地编译运行一个IDEA插件,在IDEA里聊天、下棋、斗地主!
还在找网盘资源吗?快点收藏如下几个值得收藏的网盘资源搜索神器吧!
In-depth understanding of timeout settings for Istio traffic management
[Strong Net Cup 2022] WP-UM
How to choose coins and determine the corresponding strategy research
登录功能和退出功能(瑞吉外卖)
随机推荐
Four years of weight loss record
第五章:多线程通信—wait和notify
Development common manual link sharing
单片机:温度控制DS18B20
E-sports, convenience, efficiency, security, key words for OriginOS functions
STM32+ULN2003驱动28BYJ4步进电机(根据圈数正转、反转)
Oracle 19.3 restart 环境
Voice-based social software development - making the most of its value
阿里顶级架构师多年总结的JVM宝典,哪里不会查哪里!
使用工具类把对象中的null值转换为空字符串(集合也可以使用)
The founder of the DFINITY Foundation talks about the ups and downs of the bear market, and where should DeFi projects go?
5. Deploy the web project to the cloud server
公众号如何运维?公众号运维专业团队
linux下oracle常见操作以及日常积累知识点(函数、定时任务)
力扣(LeetCode)216. 组合总和 III(2022.08.04)
首次去中心化抢劫?近2亿美元损失:跨链桥Nomad 被攻击事件分析
Why are RELTABLESPACE values 0 for many tables displayed in sys_class?
JS introduction to reverse the recycling business network of learning, simple encryption mobile phone number
three.js调试工具dat.gui使用
FPGA:基础入门LED灯闪烁