将raw格式的图像转为可以查看的png格式:
# coding:utf-8
from PIL import ImagerawData = open('Color_74.raw','rb').read()
imgSize = (640,480) ###The size of the image
# Use the PIL raw decoder to read the data.
# the 'F;16' informs the raw decoder that we are reading
# a little endian, unsigned integer 16 bit data.
img = Image.frombytes('RGB', imgSize, rawData, 'raw')
img.save("foo.png")
需要预先知道图像的尺寸,还有图像的格式,是RGB还是灰度图像等。

本文介绍了一种将RAW格式图像转换为PNG格式的方法,通过Python的PIL库实现。需预知图像尺寸及格式,适合RGB或灰度图像转换。
405

被折叠的 条评论
为什么被折叠?



