can the python PIL deal with raw image data? -
i have raw image file .bin , composed of 16 bits unsigned intergers. can python imaging library take type of file , process it? code not running , giving me invalid file type error think may error in coding rather doesn't take file type.
any knowledge on out there?
assuming file doesn't have header , tightly packed, try following:
with open('filename', 'rb') f: im = image.fromstring('l;16', (width, height), f.read()) # try 'l;16b', 'i;16', , 'i;16b' im.show() the 'l' formats truncate 16 bits per pixel 8; 'i' formats keep @ 16 bits per pixel might harder work with.
if raw file encoded in way you'll have search documentation on it, since raw formats aren't standardized @ all. .bin extension doubt that's case.
Comments
Post a Comment