How to plot 16x16 pixel image from RGB data available in Excel Sheet?

2 ビュー (過去 30 日間)
Syed Haider
Syed Haider 2014 年 2 月 18 日
コメント済み: Image Analyst 2014 年 2 月 19 日
Hello, i have R,G,B data in excel sheet for each pixel in 16x16 array. I want to generate a 16x16 image using that data. The image must be 16x16 pixels only.
Thanks,

採用された回答

Jakob Sørensen
Jakob Sørensen 2014 年 2 月 19 日
If I understand correctly, each sheet has the red (R) value in the first column, the green (G) value in the second and the blue (B) value in the third column. So with a 16x16 image, there should be 3 columns and 16 rows, in 16 sheets. Is that correct?
The function xlsread() can read one sheet at a time, making it possible to do a simple loop going through all the sheets, converting each one to a column.
% Make empty array for the image, this makes Matlab work a bit faster
img = zeros(16,16,3);
% Use a for loop to read each sheet, and insert it into a column in the image
for column = 1:16
img(:, column, :) = xlsread('NAME_OF_EXCEL_FILE.xlsx', column);
end
% Depending on the format of your data, you might have to convert to uint8
img = uint8(img);
I think that should do the trick, but without having your data, it is hard to test. Good luck with it :-)
  2 件のコメント
Syed Haider
Syed Haider 2014 年 2 月 19 日
Thanks alot :) Yea your logic worked correctly. Now i have M*N*3 data available in one variable and using Image Viewer App of MATLAB i displayed the 16*16 image. :)
Image Analyst
Image Analyst 2014 年 2 月 19 日
Or better yet, use ActiveX and do it in 1/16th of the time.

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

その他の回答 (2 件)

Image Analyst
Image Analyst 2014 年 2 月 18 日
Put it into the array using for loop. Not sure what you mean by plot, but if you want to plot you can use plot(). If you want to display as an image you can use imshow().
  1 件のコメント
Syed Haider
Syed Haider 2014 年 2 月 18 日
Thanks for the reply, yes you are rite imshow() works fine for me. But one more question please, if i have AN EXCEL SHEET with one dataset (R G B ) of column 1( means first column of image) on sheet1 and second dataset (R G B) of column2 on sheet2. How can i take input from excel. Thanks

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


Jakob Sørensen
Jakob Sørensen 2014 年 2 月 18 日
Have a look at this artcile, regarding import from a worksheet. How to turn it into an image depends a bit on how your data is arranged.
  1 件のコメント
Syed Haider
Syed Haider 2014 年 2 月 18 日
Thanks, i just looked at the article you shared here. its great. But i have different sheets in one excel file for each column of image. and each file contains RGB data for that column. Do i have to use for loop and then read the excel sheets? Thanks

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

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by