当前位置:网站首页>PIL与numpy格式之间的转换
PIL与numpy格式之间的转换
2022-08-02 05:07:00 【Mick..】
PIL是python最常见图像处理库,在深度学习中经常遇到PIL和numpy数组之间的格式变换
PIL转换为numay
from PIL import Image
img = Image.open("./hh.png")
img = np.array(img)
numay转换为PIL
from PIL import Image
import numpy as np
##生成一个随机数组
##randint()生成一定范围的数组
##random()生成0-1之间的均匀分布
##randn() 生成高斯分布
img=np.random.randint(0,255,(48,48))
img = Image.fromarray(img)
img.show()
边栏推荐
猜你喜欢

MySQL 字符串拼接 - 多种字符串拼接实战案例
![[PSQL] window function, GROUPING operator](/img/95/5c9dc06539330db907d22f84544370.png)
[PSQL] window function, GROUPING operator

MySQL如何对SQL做prepare预处理(解决IN查询SQL预处理仅能查询出一条记录的问题)

12 reasons for MySQL slow query
[email protected](using passwordYES)"/>Navicat报错:1045-Access denied for user [email protected](using passwordYES)

ApiPost 真香真强大,是时候丢掉 Postman、Swagger 了

Navicat cannot connect to mysql super detailed processing method

Detailed explanation of the software testing process (mind map) of the first-tier manufacturers

JUC(一)- JUC学习概览 - 对JUC有一个整体的认识

MySQL如何创建用户
随机推荐
C语言入门实战(13):十进制数转二进制
51单片机外设篇:DS18B20
LeetCode刷题系列 -- 787. K 站中转内最便宜的航班
复盘:图像饱和度计算公式和图像信噪(PSNR)比计算公式
21 Day Learning Challenge Schedule
关于web应用的目录结构
Go语言中定时任务库Cron使用详解
How Navicat Connects to MySQL
golang generics
51单片机外设篇:红外通信
go语言中的goroutine(协程)
本周大新闻|苹果MR已进行Pre-EVT测试,Quest 2涨价100美元
Detailed explanation of the software testing process (mind map) of the first-tier manufacturers
配合蓝牙打印的encoding-indexes.js文件内容:
How much does a test environment cost? Start with cost and efficiency
Android Studio 实现登录注册-源代码 (连接MySql数据库)
高防服务器防御的原理是什么
【C语言】LeetCode26.删除有序数组中的重复项&&LeetCode88.合并两个有序数组
Review: image saturation calculation formula and image signal-to-noise (PSNR) ratio calculation formula
ApiPost 真香真强大,是时候丢掉 Postman、Swagger 了