python-3.x - 如何在 Python 上使用 rawpy 读取图片的 RGB 值
问题描述
我正在尝试使用 Python 从 16 位“nef”图像中获取信息。
我一直在使用rawpy
图像估值器打开文件并获得线性输出。但现在我只想看绿色通道。
path = 'image.nef'
with rawpy.imread(path) as raw:
rgb_linear = raw.postprocess(gamma=(1,1),no_auto_bright=True, output_bps=16)
rgb= raw.postprocess(no_auto_bright=True, output_bps=16)
现在我不知道如何从这里获取 RGB 值。
解决方案
您可以像这样分离并保存红色、绿色和蓝色通道:
#!/usr/bin/env python3
import rawpy
import imageio
with rawpy.imread('raw.nef') as raw:
rgb = raw.postprocess(gamma=(1,1), no_auto_bright=True, output_bps=16)
# Extract Red, Green and Blue channels and save as separate files
R = rgb[:,:,0]
G = rgb[:,:,1]
B = rgb[:,:,2]
imageio.imsave('R.tif', R)
imageio.imsave('G.tif', G)
imageio.imsave('B.tif', B)
推荐阅读
- qt - 如何使用来自外部 QML 文件的内部 QML 类型?
- python - 需要从宽转换为长
- go - 在 Golang 中使用反射覆盖结构值
- bash - Bash 脚本从存储在变量中的列表创建新文件夹
- android - 使用 Material Design 主题时如何自定义 TextInputLayout?
- google-bigquery - 如何在 BigQuery 标准 SQL 中获取数组的切片?
- mysql - 我无法更新我的实体表(Spring Boot 2 hibernate 5)
- firebase - 通过电子邮件从 Firebase 发送调查链接
- r - 线性回归:行(作为观察)与变量
- python - 用于请求调用 Google Maps API 的 python 字符串编码