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

成都网站建设 Vr功能 卓 公司进一步加强网站建设

成都网站建设 Vr功能 卓 公司,进一步加强网站建设,公司网站维护怎么做,成都住建局官网楼盘销售情况文章目录 一、实验介绍二、实验环境1. 配置虚拟环境2. 库版本介绍 三、实验内容0. 导入必要的库1. PIL基础操作2~4. 随机遮挡、随机擦除、线性混合5. 图像合成5.1 原理5.2 实现5.3 效果展示 6. 图像融合6.1 原理6.2 实现6.3 效果展示 一、实验介绍 在深度学习任务中#xff0c… 文章目录 一、实验介绍二、实验环境1. 配置虚拟环境2. 库版本介绍 三、实验内容0. 导入必要的库1. PIL基础操作2~4. 随机遮挡、随机擦除、线性混合5. 图像合成5.1 原理5.2 实现5.3 效果展示 6. 图像融合6.1 原理6.2 实现6.3 效果展示 一、实验介绍 在深度学习任务中数据增强是提高模型泛化能力的关键步骤之一。通过对训练集进行变换和扩充可以有效地增加数据量引入样本之间的差异使模型更好地适应不同的输入。   本实验将继续实现自定义图像数据增强操作具体包括图像合成粘贴组合、图像融合创建高斯掩码融合两个图像 二、实验环境 1. 配置虚拟环境 conda create -n Image python3.9 conda activate Imageconda install pillow numpy2. 库版本介绍 软件包本实验版本numpy1.21.5python3.9.13pillow9.2.0 三、实验内容 0. 导入必要的库 import numpy as np from PIL import Image 1. PIL基础操作 【深度学习实验】图像处理一Python Imaging LibraryPIL库图像读取、写入、复制、粘贴、几何变换、图像增强、图像滤波 【深度学习实验】图像处理二PIL 和 PyTorchtransforms中的图像处理与随机图片增强 2~4. 随机遮挡、随机擦除、线性混合 【深度学习实验】图像处理三PIL——自定义图像数据增强操作随机遮挡、擦除、线性混合 5. 图像合成 5.1 原理 输入图像 图像1 \text{图像1} 图像1 图像2 \text{图像2} 图像2 遮挡和选择 遮挡图像1中的区域 x x x 随机选择要遮挡的图像1中的区域 x x x引入了训练数据的变异性 从图像2中选择对应区域 y y y 选择与图像1中被遮挡区域 x x x 相对应的图像2中的区域 y y y 粘贴 将 y y y 粘贴到图像1中的 x x x 位置 将从图像2中选择的区域 y y y 粘贴到图像1中被遮挡的区域 x x x 的位置模拟了一种图像混合的效果 输出 返回增强后的图像1其中现在包含了粘贴的区域 y y y。 5.2 实现 class Combine(object):def __init__(self,x_start, y_start, x_end, y_end):self.x_start x_startself.y_start y_startself.x_end x_endself.y_end y_enddef __call__(self, img1, img2):# Masking out a region x of image1img1_array np.array(img1)img1_array[self.y_start:self.y_end, self.x_start:self.x_end] 0img1_masked Image.fromarray(img1_array.astype(uint8)).convert(RGB)# Selecting a region y of the same as x from image2region_y img2.crop((self.x_start, self.y_start, self.x_end, self.y_end))# Pasting region y on the location of x of image1img1_masked.paste(region_y, (self.x_start, self.y_start))return img1_masked 5.3 效果展示 img1 Image.open(3.png).convert(RGB) img2 Image.open(2.png).convert(RGB) combine Combine(628, 128, 1012, 512) img combine(img1,img2) img.save(./combine_image.png) 6. 图像融合 6.1 原理 通过高斯核函数创建掩码以在两个图像之间进行融合。 调整样本 x j x_j xj​2.jpg的大小以匹配样本 x i x_i xi​1.jpg在 x i x_i xi​或 x j x_j xj​内选择一个随机位置 C C C使用二维标准高斯核函数创建掩码 G G G确保其中心与位置 C C C 对齐并且其大小与 x i x_i xi​ 相匹配使用 G G G 修改 x i x_i xi​并使用 1 − G 1-G 1−G 修改 x j x_j xj​将得到的修改组合在一起得到 x ^ \hat x x^返回 x ^ \hat x x^。 6.2 实现 class Gaussian(object):def __init__(self, sigma):# 混合参数self.sigma sigmadef __call__(self, img1, img2):# Choose a random position, labeled as $C$, within $x_i$ (or $x_j$)self.size img1.shape[1], img1.shape[0]print(self.size)x np.random.randint(0, img1.shape[1])y np.random.randint(0, img1.shape[0])position_c (x, y)print(position_c)# Create mask $G$ using a 2D standard Gaussian kernel function,# ensuring its center aligns with position $C$, and the size of $G$ matches that of $x_i$mask_g self.gaussian_mask(position_c)# print(mask_g.shape)mask_g np.expand_dims(mask_g, axis2)mask_g np.repeat(mask_g, 3, axis2)# print(mask_g.shape)# Use $G$ to modify $x_i$ and use $1-G$ to modify $x_j$# Combine the resulting modifications together as $\hat x$hat_x img1 * mask_g img2 * (1 - mask_g)return hat_xdef gaussian_mask(self, center):x, y np.meshgrid(np.arange(0, self.size[0]), np.arange(0, self.size[1]))d np.sqrt((x - center[0]) ** 2 (y - center[1]) ** 2)gaussian_mask np.exp(-(d ** 2 / (2.0 * self.sigma ** 2)))return gaussian_mask 6.3 效果展示 # Input two images, which are image1 (1.jpg) and image2 (2.jpg) img1 Image.open(2.png).convert(RGB) img2 Image.open(3.png).convert(RGB) # Adjust the size of Sample $x_j$ (2.jpg) to match Sample $x_i$ (1.jpg) img2 img2.resize(img1.size, Image.Resampling.BICUBIC) img1 np.array(img1) img2 np.array(img2) gaussian Gaussian(300) img gaussian(img1,img2) img Image.fromarray(img.astype(uint8)).convert(RGB) img.save(./gaussian_image.png)
http://wiki.neutronadmin.com/news/205594/

相关文章:

  • 虚拟电脑可以做网站吗菏泽做网站设计
  • 网络公司做的网站东莞公司注册地址
  • 陕西建设厅证件查询网站网页设计制作教程
  • 做视频网站赚钱嘛广西南宁建设银行招聘网站
  • 镇平微网站建设建设网站的基本流程是什么
  • 医院网站站内文章收录量多少短视频获客系统
  • 济南网站备案流程wordpress的排版
  • 旅游网站项目计划书软件定制开发服务
  • vs2010网站开发 SQL论文格式样板模板
  • 微信开发网站建设常德城乡和住房建设局网站
  • 网站名称需要用注册吗网站设计及建设合同
  • 云空间的网站品牌策划公司怎么找客户
  • 城阳做网站的做网站需要审批不
  • 爱站seo工具包官网网络营销的方式有哪些?举例说明
  • 如何建立免费的网站网站制作相关知识
  • 合肥仿站定制模板建站网站建设责任分工
  • 汇川区住房和城乡建设厅网站如何制作微信小程序店铺
  • vps被攻击网站打不开ping值高下载中国最新军事新闻
  • 海口建设网站的公司哪家好个人网站界面设计图片
  • 西安做企业网站哪家做的好网站的类型
  • 点广告挣钱网站有哪些关于动漫的网站建设
  • 建设银行网站不能登录密码邯山手机网站建设
  • 内蒙古网站seo组合wordpress源码
  • 农业基本建设项目 网站建筑室内设计公司排名
  • 网站flash效果丹阳房产网二手房
  • 南京网站建设外包云南俊发建设集团网站
  • 十大素材网站建筑新网
  • 商店网站在线设计建设银行网站首页打
  • 智能外呼系统宁波seo网络优化哪家好
  • 烟台免费网站建设东莞网站优化