当前位置:网站首页>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=行数。
示例:
边栏推荐
- What is the function of the regular expression replaceFirst() method?
- three.js调试工具dat.gui使用
- 电竞、便捷、高效、安全,盘点OriginOS功能的关键词
- 阿里顶级架构师多年总结的JVM宝典,哪里不会查哪里!
- [Strong Net Cup 2022] WP-UM
- STM32+ULN2003 drives 28BYJ4 stepper motor (forward and reverse according to the number of turns)
- [Translation] Chaos Net + SkyWalking: Better observability for chaos engineering
- 创建一个 Dapp,为什么要选择波卡?
- FPGA:基础入门按键控制LED灯
- 【AGC】增长服务1-远程配置示例
猜你喜欢

STM32+ULN2003驱动28BYJ4步进电机(根据圈数正转、反转)

【AGC】增长服务1-远程配置示例

多线程(进阶) - 2.5w字总结

2022 Huashu Cup Mathematical Modeling Question A Optimization Design Ideas for Ring Oscillators Code Sharing

语音社交软件开发——充分发挥其价值

Introduction to SD NAND Flash!

告白数字化转型时代:麦聪软件以最简单的方式让企业把数据用起来

Confessing in the era of digital transformation: Mai Cong Software allows enterprises to use data in the easiest way

PCB layout must know: teach you to correctly lay out the circuit board of the op amp

Complete image segmentation efficiently based on MindSpore and realize Dice!
随机推荐
公众号如何运维?公众号运维专业团队
2022 Huashu Cup Mathematical Modeling Question A Optimization Design Ideas for Ring Oscillators Code Sharing
【Unity】【UGUI】【在屏幕上显示文本】
three.js debugging tool dat.gui use
STM32+ULN2003 drives 28BYJ4 stepper motor (forward and reverse according to the number of turns)
[Android]如何使用RecycleView in Kotlin project
SD NAND Flash简介!
气象数据数据处理实例——matlab字符串切割匹配与R语言日期匹配(数据拼接)
Technical dry goods | Hausdorff distance for image segmentation based on MindSpore
A small test of basic grammar, Go lang1.18 introductory refining tutorial, from Bai Ding to Hongru, basic grammar of go lang and the use of variables EP02
js劫持数组push方法
技术干货 | 基于 MindSpore 实现图像分割之豪斯多夫距离
使用工具类把对象中的null值转换为空字符串(集合也可以使用)
5. Deploy the web project to the cloud server
What is SPL?
Four years of weight loss record
企业的数字化转型到底是否可以买来?
静态链接和动态链接
Egg framework usage (2)
什么是 DevOps?看这一篇就够了!