Read an 16 unsigned bits image...

Hello Everybody,
I have a question really stupid but I do not know how how to open a 16 unsigned bit image.
To do that, I use the following program:
f = fopen('ucam.dat','r');
part_corr = fread(f, 80*60, 'ubit16','ieee-be');
fclose (f);
im=reshape(part_corr,80,60);
imagesc(im')
You will find to my website the original data: http://130.120.117.103/Stations/France/TEST/ucam.dat
and what I want to obtain with matlab http://130.120.117.103/Stations/France/TEST/ucam.JPG
I hope you will find a good representation. In my doc, it is written:
16 bit color and resolution: 80x60
Thanks for advance!!!

4 comentarios

Image Analyst
Image Analyst el 9 de Ag. de 2012
Well it looks like your result is what you wanted to obtain, or more likely you just pasted the wrong link.
freluque
freluque el 9 de Ag. de 2012
Yes I have corrected the link :)
!
Image Analyst
Image Analyst el 9 de Ag. de 2012
No you didn't.
freluque
freluque el 10 de Ag. de 2012
sorry :) now it works concerning my link! I hope you will find the solution , i am a little confused about the image in matlab :(

Iniciar sesión para comentar.

 Respuesta aceptada

freluque
freluque el 13 de Ag. de 2012

0 votos

I have done this conversion and it is working... Because my pixel was coded in RGB565...
f = fopen('ucam.dat','r');
%part_corr = fread(f, 81*60, 'ubit16','ieee-be');
im=fread(f, [80, 60], '*uint16', 'ieee-be');
fclose (f);
imgR = uint8((255/31)*bitshift(bitand(im,63488),-11)); %# Red component
imgG = uint8((255/63)*bitshift(bitand(im,2016),-5)); %# Green component
imgB = uint8((255/31)*bitand(im,31)); %# Blue component
imshow(imgRGB)

Más respuestas (1)

Image Analyst
Image Analyst el 9 de Ag. de 2012

0 votos

Did you try it like this, to avoid having to reshape:
fread(fid, [80, 60], '*uint16', 'ieee-be');
and are you sure there are no header bytes you need to skip?

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 9 de Ag. de 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by