working with raw image files

MRAB python at mrabarnett.plus.com
Tue Jun 14 18:06:02 EDT 2011


On 14/06/2011 22:20, kafooster wrote:
> On 14 Cze, 22:26, MRAB<pyt... at mrabarnett.plus.com>  wrote:
>>
>> Multiply the numpy array by a scaling factor, which is
>> float(max_8bit_value) / float(max_16bit_value).
>
> could you please explain it a little? I dont understand it. like
> multiplying each element?

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()



More information about the Python-list mailing list