フィルターのクリア

how to convert a cell array into an image?

9 ビュー (過去 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

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by