필터 지우기
필터 지우기

how to convert a cell array into an image?

조회 수: 10 (최근 30일)
kanwal
kanwal 2014년 10월 4일
댓글: jumana eltrabelsi 2022년 4월 14일
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

채택된 답변

Guillaume
Guillaume 2014년 10월 5일
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
kanwal
kanwal 2014년 10월 7일
thank u so much its working.
jumana eltrabelsi
jumana eltrabelsi 2022년 4월 14일
Thank you allot, Its work for me too

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2014년 10월 4일
편집: Image Analyst 2014년 10월 4일
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
Guillaume
Guillaume 2014년 10월 5일
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 2014년 10월 6일
yeah u r right it was png. but its not decoding

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by