当前位置:网站首页>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=行数。
示例:
边栏推荐
- 第五章:多线程通信—wait和notify
- [Office] Collection of Microsoft Office download addresses (offline installation and download of Microsoft's official original version)
- 这份阿里强推的并发编程知识点笔记,将是你拿大厂offer的突破口
- Can MySQL use aggregate functions without GROUP BY?
- 单片机:温度控制DS18B20
- FPGA:开发环境Vivado的使用
- 电气工程的标准是什么
- STM32+ULN2003 drives 28BYJ4 stepper motor (forward and reverse according to the number of turns)
- 如何修改管理工具client_encoding
- Handwriting Currying - toString Comprehension
猜你喜欢
DFINITY 基金会创始人谈熊市沉浮,DeFi 项目该何去何从
FPGA: Use of the development environment Vivado
项目成本控制如何帮助项目成功?
深入理解 Istio 流量管理的超时时间设置
电竞、便捷、高效、安全,盘点OriginOS功能的关键词
2022华数杯数学建模A题环形振荡器的优化设计思路思路代码分享
【AGC】增长服务1-远程配置示例
【温度预警程序de开发】事件驱动模型实例运用
创建一个 Dapp,为什么要选择波卡?
The founder of the DFINITY Foundation talks about the ups and downs of the bear market, and where should DeFi projects go?
随机推荐
Voice-based social software development - making the most of its value
还在找网盘资源吗?快点收藏如下几个值得收藏的网盘资源搜索神器吧!
Go编译原理系列6(类型检查)
2022杭电多校 第6场 1008.Shinobu Loves Segment Tree 规律题
Confessing in the era of digital transformation: Mai Cong Software allows enterprises to use data in the easiest way
SkiaSharp 之 WPF 自绘 投篮小游戏(案例版)
Login function and logout function (St. Regis Takeaway)
How can project cost control help project success?
SQL外连接之交集、并集、差集查询
uniapp 连接ibeacon
【综合类型第 35 篇】程序员的七夕浪漫时刻
第五章:activiti流程分流判断,判断走不同的任务节点
DFINITY 基金会创始人谈熊市沉浮,DeFi 项目该何去何从
Where is your most secretive personality?
Technical dry goods | Hausdorff distance for image segmentation based on MindSpore
Handwriting Currying - toString Comprehension
如何修改管理工具client_encoding
第四章:redis 数组结构的set和一些通用命令「建议收藏」
What are the standards for electrical engineering
High-quality DeFi application building guide to help developers enjoy DeFi Summer