'How to read an Unsigned Char image file to Python?

I have an text file called with the extension '.image', at the top of the file is the following:

Image Type: unsigned char
Dimension: 2
Image Size: 512 512
Image Spacing: 1 1
Image Increment: 1 1
Image Axis Labels: "" "" 
Image Intensity Label: ""
193

I believe this to be an unsigned char file, but i'm having a hard time opening it in python (and saving it as a jpg, png etc)

Have tried the standard PIL.Image.open(), saving as a string and reading with Image.fromstring('RGB', (512,512), string), and reading as byte-like object Image.open(io.BytesIO(filepath))

Any ideas? Thanks in advance



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source