当前位置:网站首页>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=行数。
示例:
边栏推荐
- QSS 选择器
- Wei Dongshan Digital Photo Frame Project Learning (6) Transplantation of tslib
- Create a Dapp, why choose Polkadot?
- 2022 Huashu Cup Mathematical Modeling Question A Optimization Design Ideas for Ring Oscillators Code Sharing
- 高质量 DeFi 应用构建指南,助力开发者玩转 DeFi Summer
- What are the standards for electrical engineering
- 阿里全新推出:微服务突击手册,把所有操作都写出来了PDF
- Four years of weight loss record
- 如何选币与确定对应策略研究
- 5. Deploy the web project to the cloud server
猜你喜欢

皕杰报表的下拉框联动

012_SSS_ Improving Diffusion Model Efficiency Through Patching

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

RT - Thread record (a, RT, RT Thread version - Thread Studio development environment and cooperate CubeMX quick-and-dirty)

我们的Web3创业项目,黄了

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

【MindSpore易点通机器人-01】你也许见过很多知识问答机器人,但这个有点不一样

华为轻量级神经网络架构GhostNet再升级,GPU上大显身手的G-GhostNet(IJCV22)

高质量 DeFi 应用构建指南,助力开发者玩转 DeFi Summer

多线程(进阶) - 2.5w字总结
随机推荐
Oracle 19.3 restart 环境
数据中台建设(十):数据安全管理
力扣(LeetCode)216. 组合总和 III(2022.08.04)
How can project cost control help project success?
Why are RELTABLESPACE values 0 for many tables displayed in sys_class?
STM32+ULN2003 drives 28BYJ4 stepper motor (forward and reverse according to the number of turns)
SkiaSharp 之 WPF 自绘 投篮小游戏(案例版)
Egg framework usage (2)
2022 Huashu Cup Mathematical Modeling Ideas Analysis and Exchange
5. Deploy the web project to the cloud server
JS逆向入门学习之回收商网,手机号码简易加密解析
我们的Web3创业项目,黄了
What are the standards for electrical engineering
企业的数字化转型到底是否可以买来?
【Office】Microsoft Office下载地址合集(微软官方原版离线安装下载)
NowCoderTOP35-40——持续更新ing
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
第五章:redis持久化,包括rdb和aof两种方式[通俗易懂]
MySQL之数据视图
【综合类型第 35 篇】程序员的七夕浪漫时刻