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

做的网站有广告图片简述网站建设的一般流程

做的网站有广告图片,简述网站建设的一般流程,网站建设运营协议,odoo 网站页面怎么做文章目录 一、图像的旋转1、使用numpy方法实现旋转1)顺时针旋转90度2)逆时针旋转90度 2、使用opencv的方法实现图像旋转1)顺时针旋转90度2)逆时针旋转90度3)旋转180度 3、效果 二、多图像匹配1、模板2、匹配对象3、代码…

文章目录

  • 一、图像的旋转
    • 1、使用numpy方法实现旋转
      • 1)顺时针旋转90度
      • 2)逆时针旋转90度
    • 2、使用opencv的方法实现图像旋转
      • 1)顺时针旋转90度
      • 2)逆时针旋转90度
      • 3)旋转180度
    • 3、效果
  • 二、多图像匹配
    • 1、模板
    • 2、匹配对象
    • 3、代码实现
      • 1)预处理
      • 2)定义find_temp函数
      • 3)进行模板匹配
  • 三、打包与np.where()函数
    • 1、np.where()函数
      • 1)作为条件选择器
      • 2)作为条件索引获取器(省略 x 和 y)
    • 2、打包与解包
      • 1)打包
      • 2)解包


一、图像的旋转

1、使用numpy方法实现旋转

  • 读取图片并重设图片大小
import cv2
import numpy as npimg=cv2.imread("kele.png")
img=cv2.resize(img,dsize=None,fx=0.5,fy=0.5)cv2.imshow('yuantu',img)

1)顺时针旋转90度

# 旋转90度,k=-1,表示顺时针旋转90度
rotated_image1=np.rot90(img,k=-1)
cv2.imshow('totated_image1',rotated_image1)

2)逆时针旋转90度

# 旋转90度,k=-1,表示顺时针旋转90度
rotated_image1=np.rot90(img,k=-1)
cv2.imshow('totated_image1',rotated_image1)

2、使用opencv的方法实现图像旋转

1)顺时针旋转90度

rotated_image=cv2.rotate(img,cv2.ROTATE_90_CLOCKWISE)   #顺时针旋转90
cv2.imshow('shun90',img)

2)逆时针旋转90度

rotated_image1=cv2.rotate(img,cv2.ROTATE_90_COUNTERCLOCKWISE)   #逆时针旋转90度
cv2.imshow('ni90',rotated_image1)

3)旋转180度

rotated_image2=cv2.rotate(img,cv2.ROTATE_180)   #旋转180度
cv2.imshow('180',rotated_image2)
cv2.waitKey(0)

3、效果

在这里插入图片描述


二、多图像匹配

  • 这是之前写的单模板、多模板匹配,可以先去看一下方便理解:Opencv图像处理:模板匹配对象

1、模板

在这里插入图片描述

2、匹配对象

在这里插入图片描述

3、代码实现

1)预处理

import cv2
import numpy as npimg_rgb=cv2.imread('image.jpg')
img_gray=cv2.cvtColor(img_rgb,cv2.COLOR_BGR2GRAY)
template=cv2.imread('tem.jpg',0)
template1 = np.rot90(template,k=-1)
template2 = np.rot90(template,k=1)
h,w=template.shape[:2]

2)定义find_temp函数

def find_temp(temp):res=cv2.matchTemplate(img_gray,temp,cv2.TM_CCOEFF_NORMED)threshold=0.9loc=np.where(res>=threshold)for pt in zip(*loc[::-1]):cv2.rectangle(img_rgb,pt,(pt[0]+w,pt[1]+h),(0,0,255),1)

3)进行模板匹配

find_temp(template)
find_temp(template1)
find_temp(template2)
cv2.imshow('', img_rgb)
cv2.waitKey(0)

三、打包与np.where()函数

1、np.where()函数

1)作为条件选择器

np.where(condition, x=None, y=None)

  • condition:布尔数组或表达式,用于指定条件。
  • x, y(可选):当条件为 True 时返回 x 对应位置的元素,为 False 时返回 y 对应位置的元素。
  • 返回值:形状与 condition 相同的数组,元素来自 x 或 y。
import numpy as npa = np.array([1, 2, 3, 4, 5])
# 将大于 3 的元素替换为 10,否则保持原值
result = np.where(a > 3, 10, a)
print(result)  # 输出: [ 1  2  3 10 10]# 更复杂的条件(结合逻辑运算)
b = np.array([10, 20, 30, 40])
condition = (a > 2) & (b < 35)  # 同时满足两个条件
result = np.where(condition, a * 2, b // 2)
print(result)  # 输出: [ 2  4  6 20](仅前3个元素满足条件,最后一个不满足,取 b//2=20)

2)作为条件索引获取器(省略 x 和 y)

np.where(condition)

  • 作用:返回满足条件 condition 的元素的索引(以元组形式表示,每个元素对应数组的一个维度)。
  • 返回值:元组 (ind1, ind2, …, indn),其中 indi 是第 i 维满足条件的索引数组。
a = np.array([1, 2, 3, 4, 4, 5])
# 获取值为 4 的元素的索引
indices = np.where(a == 4)
print(indices)  # 输出: (array([3, 4]),)(一维数组,索引为 3 和 4)# 二维数组示例
b = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
condition = b > 5
indices = np.where(condition)
print(indices)  # 输出: (array([1, 2, 2]), array([2, 0, 1, 2])),对应行和列的索引

2、打包与解包

1)打包

a=[1,2,3]
b=[4,5,6]# 使用zip将他们按位置进行配对
zipped=zip(a,b)
print(list(zipped))
# 输出:[(1,4),(2,5),(3,6)]

2)解包

zip()将多个可迭代对象(列表、元组)进行解压操作

# 假设我们已经有了一个打包好的zip对象
zipped=zip(a,b)# #使用*运算符解包,得到转置的结果
unzipped=zip(*zipped)
loc = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]# 1. loc[::-1]:反转列表
reversed_loc = loc[::-1]
print(reversed_loc)  # 输出: [[7, 8, 9], [4, 5, 6], [1, 2, 3]]# 2. *reversed_loc:解包列表
# 此时相当于 zip([7, 8, 9], [4, 5, 6], [1, 2, 3])# 3. zip(*reversed_loc):使用 zip 函数进行打包
zipped = zip(*reversed_loc)
for pt in zipped:print(pt)
# 输出:
# (7, 4, 1)
# (8, 5, 2)
# (9, 6, 3)

http://www.dtcms.com/wzjs/109246.html

相关文章:

  • 会议网站建设百度公司官方网站
  • 信息型网站平板电视seo优化关键词
  • 福州网络公司有哪些宁波正规seo推广
  • vps怎么做多个网站中国国家培训网是真的吗
  • 网购哪个网站最好跨境电商哪个平台比较好
  • 衡水做wap网站建设2020年可用好用的搜索引擎
  • 广州建站方法优化网址
  • logo设计在线生成免费ai山东网站seo推广优化价格
  • 肥乡网站建设app拉新推广平台有哪些
  • 关键词搜索引擎网站写软文平台
  • 专业营销网站网页制作软件手机版
  • 美橙互联网站模板百度刷首页怎么刷
  • 本地的上海网站建设百度移动应用
  • 株洲网站建设公司google谷歌搜索引擎入口
  • 网站效果图怎么做的推广竞价账户托管
  • 赶集网网站建设分析湖南网站营销seo多少费用
  • 我想克隆个网站 怎么做谷歌官网首页
  • 网站更换服务器国外网站推广
  • 个人小程序开发南昌seo计费管理
  • dede 电商网站模板下载免费发布广告信息网
  • 网站开发在线播放ppt百度竞价点击神器奔奔
  • 广州注册公司挂地址费用seo技术顾问阿亮
  • 山东建设银行官网网站百度推广登录入口官网网址
  • 住房城乡建设部门户网站主页百度安装下载
  • 苏州网站建设制度微信crm系统
  • 做外贸网站企业最新天气预报最新消息
  • 网站证书怎么做优化seo方法
  • 衡水做网站推广哈尔滨优化推广公司
  • 初中生做网站挣钱百度浏览器极速版
  • tp框架网站开发参考文献成年学校培训班