working with raw image files

MRAB python at mrabarnett.plus.com
Tue Jun 14 20:24:15 EDT 2011


On 15/06/2011 00:59, kafooster wrote:
> On 15 Cze, 00:06, MRAB<pyt... at mrabarnett.plus.com>  wrote:
>
>>
>> Yes. Something like this:
>>
>> fileobj = open("hand.raw", 'rb')
>> data = numpy.fromfile(fileobj, dtype=numpy.uint16)
>> fileobj.close()
>> data = data * float(0xFF) / float(0xFFFF)
>> data = numpy.array(data, dtype=numpy.uint8)
>> data = data.reshape((96, 470, 352))
>> imshow(data[:, :, 40], cmap='gray')
>> show()
>
> thank you very much, it works and now I can display this data even
> with Image.fromarray(). As I understand, it  multiplies data elements
> by a fraction, so that when we have less levels (in 8uint), it can fit
> there?

Correct.



More information about the Python-list mailing list