フィルターのクリア

make a picture from excel file with MATLAB

7 ビュー (過去 30 日間)
baran
baran 2015 年 3 月 2 日
hi all, i have excel file which in it, there is a shape of something that specify with numbers, i want to write a code in matlab that make a picture or plot of it , that in it all the cells with same values have a color that i choose, i.e in the picture below , matlab make a picture of a Rectangular, that all cells with value of "nan" be white, and all cells with a value of "20" be red an so on.
thanks so much.

採用された回答

Joseph Cheng
Joseph Cheng 2015 年 3 月 2 日
編集済み: Joseph Cheng 2015 年 3 月 2 日
I would start by using the function xlsread() to read in the specified excel file and the range of where the image is create. Then using the == comparison you can then create the different color layers. example:
[num txt raw] = xlsread(____,____)
raw = cell2mat(raw);
Img(:,:,1) = 20==raw | isnan(raw);
Img(:,:,2) = 30==raw | isnan(raw);
Img(:,:,3) = 40==raw | isnan(raw);
  6 件のコメント
Joseph Cheng
Joseph Cheng 2015 年 3 月 3 日
well what have you tried? you can work with colormaps to define colors like
IMG = raw;
IMG(isnan(IMG))=0;
numcolor = length(unique(IMG(:)));
colors = hsv(numcolor-1);
colors= [1 1 1;colors]; %set value of 0 to be white
imagesc(IMG)
colormap(colors)
Nurfarrah Syazleen
Nurfarrah Syazleen 2023 年 6 月 6 日
what if the image is grayscale ? is the command still the same?

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

その他の回答 (1 件)

Shreya Shetty
Shreya Shetty 2019 年 7 月 26 日
Get RGB components from previous excel sheet, display them and retreive original image
[file,Path]=uigetfile('*.xlsx','Select excel file of image matrix '); file=fullfile(Path,file); red=xlsread(file, 'A1:GR200'); green=xlsread(file, 'A201:GR400'); blue=xlsread(file, 'A401:GR600'); figuresubplot(3,2,1); imshow(red,[]); imwrite(uint8(red),'red.jpg'); t1=imread('red.jpg'); title('red channel') subplot(3,2,2); imshow(green,[]); imwrite(uint8(green),'green.jpg'); t2=imread('green.jpg'); title('green channel') subplot(3,2,3); imshow(blue,[]); imwrite(uint8(blue),'blue.jpg'); title('blue channel') t3=imread('blue.jpg'); subplot(3,2,5); im=cat(3, t1, t2, t3); imshow(im) title('retreived image')

カテゴリ

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