Borrar filtros
Borrar filtros

how to convert a cell array into an image?

10 visualizaciones (últimos 30 días)
kanwal
kanwal el 4 de Oct. de 2014
Comentada: jumana eltrabelsi el 14 de Abr. de 2022
I fetched an image from sql database but its returning format is like i=[75839 int8] how can i convert it into image plz help me out

Respuesta aceptada

Guillaume
Guillaume el 5 de Oct. de 2014
If the bytes you get are truly a jpg image, you may be able to decode it with java:
jimage = javax.imageio.ImageIO.read(java.io.ByteArrayInputStream(d));
height = jimage.getHeight;
width = jimage.getWidth;
pixels = reshape(typecast(jimage.getData.getDataStorage, 'uint8'), [3,width,height]);
img = cat(3, ...
transpose(reshape(pixels(3,:,:), [width,height])), ...
transpose(reshape(pixels(2,:,:), [width,height])), ...
transpose(reshape(pixels(1,:,:), [width,height])));
  12 comentarios
kanwal
kanwal el 7 de Oct. de 2014
thank u so much its working.
jumana eltrabelsi
jumana eltrabelsi el 14 de Abr. de 2022
Thank you allot, Its work for me too

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 4 de Oct. de 2014
Editada: Image Analyst el 4 de Oct. de 2014
You need to take the (badly-named) i and reshape it into a 2 or 3D array, but you need to know the number of rows and columns.
cellContents = cell2mat(i); % Convert from cell to double.
grayImage = reshape(cellContents, [rows, columns]);
imshow(grayImage, []);
  8 comentarios
Guillaume
Guillaume el 5 de Oct. de 2014
Your image is a png image, not a jpeg. The code I posted in my answer, with the typecast fix, should decode it.
kanwal
kanwal el 6 de Oct. de 2014
yeah u r right it was png. but its not decoding

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by