python - 将元组列表转换为灰度图像,知道它的大小
问题描述
我拥有一个从 tex 提取的元组列表,它是灰度图像上像素的位置。如何使用我的列表创建 y 图像?
我尝试使用数组和 pyplot 没有成功
[(5, 160), (5, 160), (10, 387), (10, 387), (10, 387), (10, 387), (10, 387), (10, 387), (10, 387), (10, 387), (10, 387), (10, 387), (10, 387), (10, 387), (10, 387), (10, 387), (10, 387), (10, 387), (10, 387), (10, 387), (10, ...
这是名为 Position 的夫妇名单,它继续下去,还有大约 3000 对夫妇
尺寸为 598 x 513
tab=np.full((A,B),255,dtype='uint8')
for i,j in Position:
tab[i,j]=0
plt.imshow(tab,cmap='gray')
plt.show()
myarray = np.asarray(Position)
img = Image.fromarray(myarray)
img.save('test.png')
解决方案
推荐阅读
- c# - .net core 2.2 MVC:Razor 模型返回空引用异常
- visual-studio-code - 活动栏/侧边栏中的 VSCode 自定义片段列表 - 扩展推荐?
- javascript - D3.js - 根据内部文本调整工具提示宽度
- javascript - jQuery一页导航标记错误的菜单项
- http - RST,ACK 不是由 Win10 中的 FireFox/chrome 发送的,用于关闭与服务器的 SYN-ACK 数据包的连接
- php - 哪种设计模式可以减少实体集合?
- go - 如何访问上下文中的键
- excel - 使用 VBA 从日志文件或文本文档中提取两个字符串(时间间隔)之间的数据
- github - 如何获取 github 版本的 rss 提要,只有最新版本,不包括预发布?
- node.js - NodeJS 中带有 fromEvent 可观察对象和 Typescript 的 Socket.io