working with raw image files

kafooster dmozejko at gmail.com
Tue Jun 14 19:59:15 EDT 2011


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?



More information about the Python-list mailing list