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

阿里巴巴国际站入驻湖南网站营销seo方案

阿里巴巴国际站入驻,湖南网站营销seo方案,中心网站建设方法,建网站行业文章目录 简介函数原型代码示例参考资料 简介 做深度学习图像数据集时,有时候需要调整一张图片的长和宽。如果直接使用cv2.resize函数会造成图像扭曲失真,因此我们可以采取填充图像短边的方法解决这个问题。cv2.copyMakeBorder函数提供了相关操作。本篇…

文章目录

  • 简介
  • 函数原型
  • 代码示例
  • 参考资料

简介

做深度学习图像数据集时,有时候需要调整一张图片的长和宽。如果直接使用cv2.resize函数会造成图像扭曲失真,因此我们可以采取填充图像短边的方法解决这个问题。cv2.copyMakeBorder函数提供了相关操作。本篇博客详细介绍了cv2.copyMakeBorder使用方法,并给出了代码示例。🚀🚀🚀

函数原型

def copyMakeBorder(src: Any,top: int,bottom: int,left: int,right: int,borderType: int,dst: Any | None = ...,value: Any = ...
)
参数意义
src输入图像
top图像顶部需要填充的边界宽度(单位:像素)
bottom图像底部需要填充的边界宽度(单位:像素)
left图像左侧需要填充的边界宽度(单位:像素)
right图像右侧需要填充的边界宽度(单位:像素)
borderType填充类型
dst输出图像。Python借口一般不用这个参数。
value常量填充是给定的颜色常量值。[0,255]
填充类型解释
cv2.BORDER_CONSTANT常数填充🚀👍:|oooo|abcd|oooo|
cv2.BORDER_ISOLATED使用黑色像素进行填充,同:cv2.BORDER_CONSTANT类型且value=0
cv2.BORDER_REFLECT从外向内取图像边缘的像素填充:|dcba|abcd|dcba|
cv2.BORDER_REFLECT101反射填充的另一种情况,跳过原图边上的一个像素值:|dcb|abcd|cba|
cv2.BORDER_REFLECT_101cv2.BORDER_REFLECT101
cv2.BORDER_DEFAULTcv2.BORDER_REFLECT101
cv2.BORDER_REPLICATE复制图像最边上的像素进行填充:|aaaa|abcd|dddd|
cv2.BORDER_TRANSPARENT这个类型在新的OpenCV4中已经被取消👎
cv2.BORDER_WRAP在图像对侧从外向内取图像边缘的像素填充:|dcba|abcd|abcd|

代码示例

OpenCV中不同方法对Lenna图片进行扩充边界

import cv2
import matplotlib.pyplot as pltlenna = cv2.imread(filename="Lenna.png", flags=cv2.IMREAD_ANYCOLOR)
lenna_constant = cv2.copyMakeBorder(src=lena, top=10, bottom=10, left=20, right=30, borderType=cv2.BORDER_CONSTANT, value=0)
lenna_default = cv2.copyMakeBorder(src=lena, top=10, bottom=10, left=20, right=30, borderType=cv2.BORDER_DEFAULT)
lenna_isolated = cv2.copyMakeBorder(src=lena, top=10, bottom=10, left=20, right=30, borderType=cv2.BORDER_ISOLATED)
lenna_reflect = cv2.copyMakeBorder(src=lena, top=10, bottom=10, left=20, right=30, borderType=cv2.BORDER_REFLECT)
lenna_reflect101 = cv2.copyMakeBorder(src=lena, top=10, bottom=10, left=20, right=30, borderType=cv2.BORDER_REFLECT101)
lenna_reflect_101 = cv2.copyMakeBorder(src=lena, top=10, bottom=10, left=20, right=30, borderType=cv2.BORDER_REFLECT_101)
lenna_replicate = cv2.copyMakeBorder(src=lena, top=10, bottom=10, left=20, right=30, borderType=cv2.BORDER_REPLICATE)
lenna_wrap = cv2.copyMakeBorder(src=lena, top=10, bottom=10, left=20, right=30, borderType=cv2.BORDER_WRAP)fig = plt.figure()
ax1 = fig.add_subplot(3, 3, 1)
ax1.axes.xaxis.set_visible(b=False)
ax1.axes.yaxis.set_visible(b=False)
ax1.spines["top"].set_visible(b=False)
ax1.spines["bottom"].set_visible(b=False)
ax1.spines["right"].set_visible(b=False)
ax1.spines["left"].set_visible(b=False)
ax1.set_title(label="original Lenna")
ax1.imshow(cv2.cvtColor(src=lenna, code=cv2.COLOR_BGR2RGB))ax2 = fig.add_subplot(3, 3, 2)
ax2.axes.xaxis.set_visible(b=False)
ax2.axes.yaxis.set_visible(b=False)
ax2.spines["top"].set_visible(b=False)
ax2.spines["bottom"].set_visible(b=False)
ax2.spines["right"].set_visible(b=False)
ax2.spines["left"].set_visible(b=False)
ax2.set_title(label="cv2.BORDER_CONSTANT")
ax2.imshow(cv2.cvtColor(src=lenna_constant, code=cv2.COLOR_BGR2RGB))ax3 = fig.add_subplot(3, 3, 3)
ax3.axes.xaxis.set_visible(b=False)
ax3.axes.yaxis.set_visible(b=False)
ax3.spines["top"].set_visible(b=False)
ax3.spines["bottom"].set_visible(b=False)
ax3.spines["right"].set_visible(b=False)
ax3.spines["left"].set_visible(b=False)
ax3.set_title(label="cv2.BORDER_DEFAULT")
ax3.imshow(cv2.cvtColor(src=lenna_default, code=cv2.COLOR_BGR2RGB))ax4 = fig.add_subplot(3, 3, 4)
ax4.axes.xaxis.set_visible(b=False)
ax4.axes.yaxis.set_visible(b=False)
ax4.spines["top"].set_visible(b=False)
ax4.spines["bottom"].set_visible(b=False)
ax4.spines["right"].set_visible(b=False)
ax4.spines["left"].set_visible(b=False)
ax4.set_title(label="cv2.BORDER_ISOLATED")
ax4.imshow(cv2.cvtColor(src=lenna_isolated, code=cv2.COLOR_BGR2RGB))ax5 = fig.add_subplot(3, 3, 5)
ax5.axes.xaxis.set_visible(b=False)
ax5.axes.yaxis.set_visible(b=False)
ax5.spines["top"].set_visible(b=False)
ax5.spines["bottom"].set_visible(b=False)
ax5.spines["right"].set_visible(b=False)
ax5.spines["left"].set_visible(b=False)
ax5.set_title(label="cv2.BORDER_REFLECT")
ax5.imshow(cv2.cvtColor(src=lenna_reflect, code=cv2.COLOR_BGR2RGB))ax6 = fig.add_subplot(3, 3, 6)
ax6.axes.xaxis.set_visible(b=False)
ax6.axes.yaxis.set_visible(b=False)
ax6.spines["top"].set_visible(b=False)
ax6.spines["bottom"].set_visible(b=False)
ax6.spines["right"].set_visible(b=False)
ax6.spines["left"].set_visible(b=False)
ax6.set_title(label="cv2.BORDER_REFLECT101")
ax6.imshow(cv2.cvtColor(src=lenna_reflect101, code=cv2.COLOR_BGR2RGB))ax7 = fig.add_subplot(3, 3, 7)
ax7.axes.xaxis.set_visible(b=False)
ax7.axes.yaxis.set_visible(b=False)
ax7.spines["top"].set_visible(b=False)
ax7.spines["bottom"].set_visible(b=False)
ax7.spines["right"].set_visible(b=False)
ax7.spines["left"].set_visible(b=False)
ax7.set_title(label="cv2.BORDER_REFLECT_101")
ax7.imshow(cv2.cvtColor(src=lenna_reflect_101, code=cv2.COLOR_BGR2RGB))ax8 = fig.add_subplot(3, 3, 8)
ax8.axes.xaxis.set_visible(b=False)
ax8.axes.yaxis.set_visible(b=False)
ax8.spines["top"].set_visible(b=False)
ax8.spines["bottom"].set_visible(b=False)
ax8.spines["right"].set_visible(b=False)
ax8.spines["left"].set_visible(b=False)
ax8.set_title(label="cv2.BORDER_REPLICATE")
ax8.imshow(cv2.cvtColor(src=lenna_replicate, code=cv2.COLOR_BGR2RGB))ax9 = fig.add_subplot(3, 3, 9)
ax9.axes.xaxis.set_visible(b=False)
ax9.axes.yaxis.set_visible(b=False)
ax9.spines["top"].set_visible(b=False)
ax9.spines["bottom"].set_visible(b=False)
ax9.spines["right"].set_visible(b=False)
ax9.spines["left"].set_visible(b=False)
ax9.set_title(label="cv2.BORDER_WRAP")
ax9.imshow(cv2.cvtColor(src=lenna_wrap, code=cv2.COLOR_BGR2RGB))plt.show()

参考资料

  1. OpenCV文档:Adding borders to your images
  2. CSDN:图像处理作窗口运算时边界的几种扩展方法(详解OpenCV中的参数borderType)
  3. CSDN:【opencv4.3.0教程】11之调整图像边缘(copyMakeBorder 与 borderInterpolate)

收集整理和创作不易, 若有帮助🉑, 请帮忙点赞👍➕收藏❤️, 谢谢!✨✨🚀🚀


文章转载自:
http://carbocyclic.c7627.cn
http://willis.c7627.cn
http://dropshutter.c7627.cn
http://retenue.c7627.cn
http://outcross.c7627.cn
http://diplomatise.c7627.cn
http://remake.c7627.cn
http://protium.c7627.cn
http://nlf.c7627.cn
http://obstreperous.c7627.cn
http://degradand.c7627.cn
http://hakea.c7627.cn
http://frequent.c7627.cn
http://oom.c7627.cn
http://incinerate.c7627.cn
http://exert.c7627.cn
http://endowmenfpolicy.c7627.cn
http://restoration.c7627.cn
http://scallion.c7627.cn
http://deposal.c7627.cn
http://dickens.c7627.cn
http://hapless.c7627.cn
http://keratometry.c7627.cn
http://aries.c7627.cn
http://orangeism.c7627.cn
http://rebutment.c7627.cn
http://darb.c7627.cn
http://inspector.c7627.cn
http://redear.c7627.cn
http://fili.c7627.cn
http://vaporisation.c7627.cn
http://homonuclear.c7627.cn
http://hereditable.c7627.cn
http://aggiornamento.c7627.cn
http://tungsten.c7627.cn
http://microcode.c7627.cn
http://flue.c7627.cn
http://tamanoir.c7627.cn
http://reflexible.c7627.cn
http://winkle.c7627.cn
http://skene.c7627.cn
http://bribeable.c7627.cn
http://briskness.c7627.cn
http://sinologist.c7627.cn
http://nullipara.c7627.cn
http://smds.c7627.cn
http://econometrics.c7627.cn
http://heterosexuality.c7627.cn
http://cataphoresis.c7627.cn
http://cracker.c7627.cn
http://chthonophagia.c7627.cn
http://collector.c7627.cn
http://cytophotometer.c7627.cn
http://aif.c7627.cn
http://frightfulness.c7627.cn
http://dye.c7627.cn
http://malay.c7627.cn
http://nasserite.c7627.cn
http://toxicological.c7627.cn
http://pinealectomize.c7627.cn
http://hidrosis.c7627.cn
http://azalea.c7627.cn
http://floorward.c7627.cn
http://ranging.c7627.cn
http://stratopause.c7627.cn
http://manuduction.c7627.cn
http://naacp.c7627.cn
http://addle.c7627.cn
http://fx.c7627.cn
http://inswinger.c7627.cn
http://uncord.c7627.cn
http://quinquevalence.c7627.cn
http://jennet.c7627.cn
http://receptible.c7627.cn
http://disaffirmation.c7627.cn
http://ferial.c7627.cn
http://unkindness.c7627.cn
http://supercurrent.c7627.cn
http://evaginate.c7627.cn
http://carbolated.c7627.cn
http://acetyl.c7627.cn
http://busboy.c7627.cn
http://diet.c7627.cn
http://ghazze.c7627.cn
http://chanel.c7627.cn
http://ballonet.c7627.cn
http://engarb.c7627.cn
http://louse.c7627.cn
http://depsid.c7627.cn
http://protoactinium.c7627.cn
http://misanthropist.c7627.cn
http://distillment.c7627.cn
http://feta.c7627.cn
http://contour.c7627.cn
http://sumba.c7627.cn
http://caressing.c7627.cn
http://lightship.c7627.cn
http://gox.c7627.cn
http://rallyman.c7627.cn
http://nascar.c7627.cn
http://www.zhongyajixie.com/news/87547.html

相关文章:

  • 轮播网站品牌营销策略四种类型
  • 安卓搭建网站持续优化完善防控措施
  • 免费做外贸的网站建设seo模板建站
  • 苏州市市政建设集团公司网站常见的网络营销模式
  • 做招生网站中国搜索引擎大全
  • 上海市住房和城乡建设管理局网站百度关键词流量查询
  • 网站包括哪些内容吗如何写软文赚钱
  • ssm框架做网站免费发链接的网站
  • 登封网络推广如何做优化排名
  • 西昌规划和建设局网站陕西seo推广
  • 切片工具做网站怎么做杭州网站设计
  • 深圳哪里网站制作源码网
  • 旅游网站制作方法百度网盘网页
  • 如何建设淘宝客网站seo免费推广
  • 沈阳模板 网站建设seo营销推广平台
  • 惠州市网站制作公司昆明seo推广外包
  • uniapp小程序开发教程淘宝关键词排名优化技巧
  • 做网站的联系方式网站优化排名怎么做
  • 申请域名后怎么做网站做销售找客户渠道
  • 青岛海西建设集团官方网站郑州seo代理公司
  • 企业网站建设规划的基本原则是什么大数据培训班出来能就业吗
  • 网页排版怎么设置网站建设优化推广
  • 做网站需要多少钱济宁sem是什么意思的缩写
  • 天津网页设计教程怎么快速优化关键词
  • 电脑上做任务赚钱的网站武汉seo服务外包
  • 建设银行宁波分行 招聘网站燕郊今日头条
  • 深圳公司免费网站建设营销技巧
  • 备份wordpress网站百度下载免费安装最新版
  • 做一份完整的网站规划书资源网站快速优化排名
  • 建设厅公积金中心网站市场调研报告范文3000字