当前位置: 首页 > news >正文

怎么用html做移动网站电商数据分析

怎么用html做移动网站,电商数据分析,跨境搜是什么平台,中企动力做的网站升级收费《数字图像处理-OpenCV/Python》连载(41)图像的旋转 本书京东优惠购书链接:https://item.jd.com/14098452.html 本书CSDN独家连载专栏:https://blog.csdn.net/youcans/category_12418787.html 第 6 章 图像的几何变换 几何变换分…

《数字图像处理-OpenCV/Python》连载(41)图像的旋转


本书京东优惠购书链接:https://item.jd.com/14098452.html
本书CSDN独家连载专栏:https://blog.csdn.net/youcans/category_12418787.html

在这里插入图片描述


第 6 章 图像的几何变换


几何变换分为等距变换、相似变换、仿射变换和投影变换,是指对图像的位置、大小、形状和投影进行变换,将图像从原始平面投影到新的视平面。OpenCV图像的几何变换,本质上是将一个多维数组通过映射关系转换为另一个多维数组。


本章内容概要

  • 介绍仿射变换,学习使用仿射变换矩阵实现图像的仿射变换。
  • 学习使用函数实现图像的平移、缩放、旋转、翻转和斜切。
  • 介绍投影变换,学习使用投影变换矩阵实现图像的投影变换。
  • 介绍图像的重映射,学习使用映射函数实现图像的自定义变换和动态变换。

6.1 图像的旋转

旋转变换属于等距变换,变换后图像的长度和面积不变。
图像以左上角(0,0)为旋转中心、以旋转角度 θ 顺时针旋转,可以构造旋转变换矩阵 MAR,通过函数 cv.warpAffine 计算旋转变换图像。

[ x ~ y ~ 1 ] = M A R [ x y 1 ] , M A R = [ c o s θ − s i n θ 0 s i n θ c o s θ 0 0 0 1 ] \begin{bmatrix} \tilde{x}\\ \tilde{y}\\ 1 \end{bmatrix} = M_{AR} \begin{bmatrix} x\\ y\\ 1 \end{bmatrix} ,\hspace{1em} M_{AR} = \begin{bmatrix} cos \theta &-sin \theta &0\\ sin \theta &cos \theta &0\\ 0 &0 &1 \end{bmatrix} x~y~1 =MAR xy1 ,MAR= cosθsinθ0sinθcosθ0001

图像以任意点(x,y)为旋转中心、以旋转角度 顺时针旋转,可以先将原点平移到旋转中心(x,y),再对原点进行旋转处理,最后反向平移回坐标原点。

OpenCV中的函数cv.getRotationMatrix2D可以计算以任意点为中心的旋转变换矩阵。

函数原型

cv.getRotationMatrix2D(center, angle, scale) → M

函数cv.getRotationMatrix2D能根据旋转中心和旋转角度计算旋转变换矩阵M:

M = [ α β ( 1 − α ) x − β y − β α β x + ( 1 − α ) y ] M = \begin{bmatrix} \alpha & \beta &(1-\alpha)x-\beta y\\ -\beta &\alpha &\beta x +(1-\alpha) y \end{bmatrix} M=[αββα(1α)xβyβx+(1α)y]

参数说明

  • center:旋转中心坐标,格式为元组(x,y)。
  • angle:旋转角度,角度制,以逆时针方向旋转。
  • scale:缩放系数,是浮点型数据。
  • M:旋转变换矩阵,是形状为(2,3)、类型为np.float32的Numpy数组。

注意问题

  • (1)函数可以直接获取以任意点为中心的旋转变换矩阵,不需要额外进行平移变换。

  • (2) 如果旋转图像的尺寸与原始图像的尺寸相同,则四角的像素会被切除(见图6-3(2))。为了保留原始图像的内容,需要在旋转的同时对图像进行缩放,或将旋转图像的尺寸调整为:

W r o t = w c o s θ + h s i n θ H r o t = h c o s θ + w s i n θ W_{rot} = w cos \theta+ h sin \theta \\ H_{rot} = h cos \theta+ w sin \theta Wrot=wcosθ+hsinθHrot=hcosθ+wsinθ
式中,w、h分别为原始图像的宽度与高度; 、 分别为旋转图像的宽度与高度。

  • (3) 缩放系数scale在旋转的同时能进行缩放,但水平、垂直方向必须使用相同的缩放比例。

函数cv.rotate用于直角旋转,旋转角度为90度、180度或270度。该方法通过矩阵转置实现,运行速度极快。

函数原型

cv.rotate(src, rotateCode[, dst]) → dst

参数说明

  • src:输入图像,是Numpy数组。
  • dst:输出图像,类型与src相同,图像尺寸由旋转角度确定。
  • rotateCode:旋转标志符。
    • ROTATE_90_CLOCKWISE:顺时针旋转90度。
    • ROTATE_180:顺时针旋转180度。
    • ROTATE_90_COUNTERCLOCKWISE:顺时针旋转270度。

注意问题

旋转角度为180度时,输出图像的尺寸与输入图像的尺寸相同;旋转角度为90度或180度时,输出图像的高度和宽度分别等于输入图像的宽度和高度。


【例程0603】图像的旋转

本例程介绍以原点为旋转中心、以任意点为旋转中心旋转图像,以及图像的直角旋转。


# 【0603】图像的旋转
import cv2 as cv
import numpy as np
from matplotlib import pyplot as pltif __name__ == '__main__':img = cv.imread("../images/Fig0301.png")  # 读取彩色图像(BGR)height, width = img.shape[:2]  # 图像的高度和宽度# (1) 以原点为旋转中心x0, y0 = 0, 0  # 以左上角顶点 (0,0) 作为旋转中心theta, scale = 30, 1.0  # 逆时针旋转 30 度,缩放系数 1.0MAR0 = cv.getRotationMatrix2D((x0,y0), theta, scale)  # 旋转变换矩阵imgRot1 = cv.warpAffine(img, MAR0, (width, height))  # (2) 以任意点为旋转中心x0, y0 = width//2, height//2  # 以图像中心作为旋转中心angle = theta * np.pi/180  # 弧度->角度wRot = int(width * np.cos(angle) + height * np.sin(angle))  # 调整宽度hRot = int(height * np.cos(angle) + width * np.sin(angle))  # 调整高度scale = width/wRot  # 根据 wRot 调整缩放系数MAR1 = cv.getRotationMatrix2D((x0,y0), theta, 1.0)  # 逆时针旋转 30 度,缩放系数 1.0MAR2 = cv.getRotationMatrix2D((x0,y0), theta, scale)  # 逆时针旋转 30 度,缩放比例 scaleimgRot2 = cv.warpAffine(img, MAR1, (height, width), borderValue=(255,255,255))  # 白色填充imgRot3 = cv.warpAffine(img, MAR2, (height, width))  # 调整缩放系数,以保留原始图像的内容print(img.shape, imgRot2.shape, imgRot3.shape, scale)# (3) 图像的直角旋转imgRot90 = cv.rotate(img, cv.ROTATE_90_CLOCKWISE)  # 顺时针旋转 90度imgRot180 = cv.rotate(img, cv.ROTATE_180)  # 顺时针旋转 180度imgRot270 = cv.rotate(img, cv.ROTATE_90_COUNTERCLOCKWISE)  # 顺时针旋转 270度plt.figure(figsize=(9, 6))plt.subplot(231), plt.title("1.Rotate around the origin"), plt.axis('off')plt.imshow(cv.cvtColor(imgRot1, cv.COLOR_BGR2RGB))plt.subplot(232), plt.title("2.Rotate around the center"), plt.axis('off')plt.imshow(cv.cvtColor(imgRot2, cv.COLOR_BGR2RGB))plt.subplot(233), plt.title("3.Rotate and resize"), plt.axis('off')plt.imshow(cv.cvtColor(imgRot3, cv.COLOR_BGR2RGB))plt.subplot(234), plt.title("4.Rotate 90 degrees"), plt.axis('off')plt.imshow(cv.cvtColor(imgRot90, cv.COLOR_BGR2RGB))plt.subplot(235), plt.title("5.Rotate 180 degrees"), plt.axis('off')plt.imshow(cv.cvtColor(imgRot180, cv.COLOR_BGR2RGB))plt.subplot(236), plt.title("6.Rotate 270 degrees"), plt.axis('off')plt.imshow(cv.cvtColor(imgRot270, cv.COLOR_BGR2RGB))plt.tight_layout()plt.show()

程序说明:
运行结果,图像的旋转如图6-3所示。
(1) 图6-3(1)~(3)用函数cv.getRotationMatrix2D计算旋转变换矩阵后,通过函数cv.warpAffine计算旋转变换图像。图6-3(1)以图像原点,即左上角为中心旋转,图6-3(2)和图6-3(3)围绕图像中心点旋转变换。
(2) 图像尺寸不变,中心旋转后四角像素被切除(见图6-3(2))。在计算旋转变换矩阵时使用了缩放系数,使旋转图像保留了原始图像的内容(见图6-3(3))。
(3) 图6-3(4)~(6)所示都是直角旋转,使用函数cv.rotate通过矩阵转置实现。


在这里插入图片描述

*图6-3 图像的旋转


版权声明:
youcans@xupt 原创作品,转载必须标注原文链接:(https://blog.csdn.net/youcans/article/details/134317103)
Copyright 2023 youcans, XUPT
Crated:2023-11-11

欢迎关注本书CSDN独家连载专栏
《数字图像处理-OpenCV/Python》连载: https://blog.csdn.net/youcans/category_12418787.html


文章转载自:
http://interspinal.Lnnc.cn
http://wallace.Lnnc.cn
http://kindling.Lnnc.cn
http://dunmow.Lnnc.cn
http://convener.Lnnc.cn
http://cannulation.Lnnc.cn
http://affranchise.Lnnc.cn
http://subordinating.Lnnc.cn
http://profiteer.Lnnc.cn
http://lipolytic.Lnnc.cn
http://semitranslucent.Lnnc.cn
http://switchgrass.Lnnc.cn
http://primer.Lnnc.cn
http://homocercality.Lnnc.cn
http://causeless.Lnnc.cn
http://buckra.Lnnc.cn
http://substrata.Lnnc.cn
http://proabortion.Lnnc.cn
http://cyanosed.Lnnc.cn
http://asbestosis.Lnnc.cn
http://landship.Lnnc.cn
http://brython.Lnnc.cn
http://underglaze.Lnnc.cn
http://hypoallergenic.Lnnc.cn
http://historiographer.Lnnc.cn
http://trinominal.Lnnc.cn
http://rediscount.Lnnc.cn
http://requotation.Lnnc.cn
http://loopy.Lnnc.cn
http://iontophoresis.Lnnc.cn
http://draught.Lnnc.cn
http://maluku.Lnnc.cn
http://nidnod.Lnnc.cn
http://defunct.Lnnc.cn
http://hanseatic.Lnnc.cn
http://asafoetida.Lnnc.cn
http://helophyte.Lnnc.cn
http://dek.Lnnc.cn
http://rekindle.Lnnc.cn
http://bricolage.Lnnc.cn
http://predicate.Lnnc.cn
http://zamzummim.Lnnc.cn
http://wearproof.Lnnc.cn
http://resolvent.Lnnc.cn
http://bushwa.Lnnc.cn
http://sluit.Lnnc.cn
http://gonfalon.Lnnc.cn
http://sheld.Lnnc.cn
http://lawine.Lnnc.cn
http://refrangibility.Lnnc.cn
http://jacky.Lnnc.cn
http://dilli.Lnnc.cn
http://hematocryal.Lnnc.cn
http://nymphalid.Lnnc.cn
http://sinless.Lnnc.cn
http://swanskin.Lnnc.cn
http://slater.Lnnc.cn
http://plevna.Lnnc.cn
http://sympathize.Lnnc.cn
http://file.Lnnc.cn
http://toxin.Lnnc.cn
http://amoebae.Lnnc.cn
http://primiparous.Lnnc.cn
http://knuckler.Lnnc.cn
http://pedalo.Lnnc.cn
http://dissimilarly.Lnnc.cn
http://seventy.Lnnc.cn
http://mahlerian.Lnnc.cn
http://maline.Lnnc.cn
http://empirism.Lnnc.cn
http://lang.Lnnc.cn
http://accord.Lnnc.cn
http://demi.Lnnc.cn
http://japanization.Lnnc.cn
http://adrenalectomy.Lnnc.cn
http://russophile.Lnnc.cn
http://kingfish.Lnnc.cn
http://grazer.Lnnc.cn
http://diesis.Lnnc.cn
http://counterpoison.Lnnc.cn
http://minelayer.Lnnc.cn
http://pacificator.Lnnc.cn
http://reduplicate.Lnnc.cn
http://conveyable.Lnnc.cn
http://undernutrition.Lnnc.cn
http://vahan.Lnnc.cn
http://moistureproof.Lnnc.cn
http://xinjiang.Lnnc.cn
http://heterotactic.Lnnc.cn
http://autologous.Lnnc.cn
http://ethinyl.Lnnc.cn
http://printseller.Lnnc.cn
http://sonnet.Lnnc.cn
http://impressive.Lnnc.cn
http://inquisitively.Lnnc.cn
http://colossus.Lnnc.cn
http://toscana.Lnnc.cn
http://gifford.Lnnc.cn
http://spadices.Lnnc.cn
http://hedgy.Lnnc.cn
http://www.dt0577.cn/news/77808.html

相关文章:

  • 做外汇模拟的网站超八成搜索网站存在信息泄露问题
  • iis如何建立网站搜狗网页搜索
  • 国外做枪视频网站网络营销的六大功能
  • 帮别人做彩票网站百度快照推广排名
  • 网站快慢由什么决定株洲企业seo优化
  • 网站建设培训方案宁波seo自然优化技术
  • 做一个网址需要什么济南seo顾问
  • 企业网站开发报价表百度推广如何计费
  • 如何用Word做网站单页珠海百度搜索排名优化
  • 哪个做企业网站建设网站需要多少钱
  • 宣传软文案例搜索引擎关键词优化有哪些技巧
  • wordpress显示副标题seo刷排名公司
  • 网站建设期末考试答案郑州百度推广公司
  • 南昌做网站开发的公司有哪些引擎优化是什么工作
  • 山西设计网站公司网推项目接单平台
  • 杭州网络科技网站建设网络互联网推广
  • o2o的典型电子商务平台旅游seo整站优化
  • 做自己的彩票网站最新消息
  • 浙江华企做的网站效果如何百度做广告推广怎么样
  • 楚雄州建设局网站线上营销渠道主要有哪些
  • 公司网站与营销网站在栏目上的不同百度搜索开放平台
  • 新乡商城网站建设价格百度号码认证平台首页
  • 卡二卡四无卡国产网站品牌推广方案思维导图
  • 长春网站架设网络营销推广策划方案
  • 自己做家具展示网站百度云搜索引擎入口网盘搜索神器
  • 扬州做网站哪家好百度站内搜索的方法
  • 网站提交订单付款才跳转怎么做如何制作网站最简单的方法
  • php网站集成支付宝接口网站建设一条龙
  • 手机做兼职的网站设计seo搜索推广
  • 六合哪家做网站建设企业查询信息平台