Re: working with raw image files

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

Re: working with raw image files

2011-06-14 Thread Nobody
On Tue, 14 Jun 2011 13:13:07 -0700, kafooster wrote: > 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

Re: working with raw image files

2011-06-14 Thread Nobody
On Tue, 14 Jun 2011 19:25:32 -0400, Dave Angel wrote: > You said in an earlier message to ignore the RAW format. However, if > your file matches a typical camera's raw file It doesn't. He's dealing with a raw array of fixed-size integers (i.e. what you would get if you took a C array and wrote

Re: working with raw image files

2011-06-14 Thread MRAB
On 15/06/2011 00:59, kafooster wrote: 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.

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 please explain it a little? I dont understand it

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 Dave Angel
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 please explain it a little? I dont understand it. like multiplying each element? You said in an earlie

Re: working with raw image files

2011-06-14 Thread MRAB
On 14/06/2011 22:20, 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 please explain it a little? I dont understand it. like multiplying each element? Yes. Something like this: f

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 Dan Stromberg
On Tue, Jun 14, 2011 at 1:26 PM, MRAB wrote: > On 14/06/2011 21:13, kafooster wrote: > >> >> I would like to visualize this data with PIL, but PIL works only with >> 8bit data. How could I resample my array from 16bit to 8bit? >> > > Multiply the numpy array by a scaling factor, which is > float(

Re: working with raw image files

2011-06-14 Thread MRAB
On 14/06/2011 21:13, kafooster wrote: 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

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-14 Thread Terry Reedy
On 6/14/2011 3:49 AM, Martin De Kauwe wrote: what is a .raw file, do you mean a flat binary? Perhaps tiff-like. https://secure.wikimedia.org/wikipedia/en/wiki/Raw_image_format "Providing a detailed and concise description of the content of raw files is highly problematic. There is no single ra

Re: working with raw image files

2011-06-14 Thread Martin De Kauwe
what is a .raw file, do you mean a flat binary? -- http://mail.python.org/mailman/listinfo/python-list

Re: working with raw image files

2011-06-13 Thread Wanderer
On Jun 13, 4:58 pm, kafooster wrote: > 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 cl

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 Image.open cannot > > handle .ra

Re: working with raw image files

2011-06-13 Thread Wanderer
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 Image.open cannot > handle .raw since i get error > >     image1 = Image.open

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

Re: working with raw image files

2011-06-13 Thread MRAB
On 13/06/2011 21:20, Wanderer wrote: On Jun 13, 4:08 pm, Wanderer wrote: On Jun 13, 2:18 pm, kafooster wrote: 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

Re: working with raw image files

2011-06-13 Thread Wanderer
On Jun 13, 4:08 pm, Wanderer wrote: > On Jun 13, 2:18 pm, kafooster wrote: > > > > > > > > > > > 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 medic

Re: working with raw image files

2011-06-13 Thread Wanderer
On Jun 13, 2:18 pm, kafooster wrote: > 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,

Re: working with raw image files

2011-06-13 Thread Terry Reedy
On 6/13/2011 2:18 PM, kafooster wrote: 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 di

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