Re: working with raw image files

2011-06-14 Thread kafooster
On 15 Cze, 01:25, Dave Angel wrote: > On 01/-10/-28163 02:59 PM, kafooster wrote: > > > On 14 Cze, 22:26, MRAB  wrote: > > >> Multiply the numpy array by a scaling factor, which is > >> float(max_8bit_value) / float(max_16bit_value). > > > could you ple

Re: working with raw image files

2011-06-14 Thread kafooster
On 15 Cze, 00:06, MRAB wrote: > > Yes. Something like this: > > fileobj = open("hand.raw", 'rb') > data = numpy.fromfile(fileobj, dtype=numpy.uint16) > fileobj.close() > data = data * float(0xFF) / float(0x) > data = numpy.array(data, dtype=numpy.uint8) > data = data.reshape((96, 470, 352)) >

Re: working with raw image files

2011-06-14 Thread kafooster
On 14 Cze, 22:26, MRAB 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? -- http://mail.python.org/mailman/listinfo/python-list

Re: working with raw image files

2011-06-14 Thread kafooster
Ok, I solved the problem with matplotlib fileobj = open("hand.raw", 'rb') data = numpy.fromfile(fileobj,dtype=np.uint16) data = numpy.reshape(data,(96,470,352)) imshow(data[:,:,40],cmap='gray') show() the error was caused by different order of data, however it still reads the dataset as half of i

Re: working with raw image files

2011-06-13 Thread kafooster
On 13 Cze, 22:52, Wanderer wrote: > On Jun 13, 4:41 pm, kafooster wrote: > > > Wanderer: by *.raw I mean images with .raw extension, pure pixel data > > without headerhttp://en.wikipedia.org/wiki/Raw_image_format > > > That is a clear and nice code however I think I

Re: working with raw image files

2011-06-13 Thread kafooster
Wanderer: by *.raw I mean images with .raw extension, pure pixel data without header http://en.wikipedia.org/wiki/Raw_image_format That is a clear and nice code however I think Image.open cannot handle .raw since i get error image1 = Image.open("hand.raw", "rb") File "D:\Python27\lib\site-p

working with raw image files

2011-06-13 Thread kafooster
I am working on some medical image data, and I try to look into specific slice of 3d *.raw image. I know voxels are 16 bit int, and dimensions are 352*470*96. I checked it in some pro medical image viewer, it is alright. However, with the code I use, I display just white noise image.(but worked