Hello Everybody,
Due an internship assignment i'm using matlab. I haven't got many experience with it. My question is;
This is part of my code that i'm trying to get work. The meaning is to set a batch of images to grayscale and then crop at the given coördinates. After that i need to get the information of the average gray value and write that to excel. I can do it for one image, but i need to get a table with the information. the first value need to be written in 'B2' the next one in 'B3' the 3rd one in 'b4' etc.
Can someone help me with it?
Kind regards
Hilbrand

 採用された回答

Thorsten
Thorsten 2015 年 9 月 22 日

1 投票

You should compute the mean gray values of all images in the for loop as follows
B2(i) = mean2(I1);
B3(i) = mean2(I2);
B4(i) = mean2(I3);
Outside the for loop you then write the three B vectors to their specific sheets
xlswrite(filenamexlsx,B2,'B2');
xlswrite(filenamexlsx,B3,'B3');
xlswrite(filenamexlsx,B4,'B4');

3 件のコメント

N/A
N/A 2015 年 9 月 22 日
Hello,
when i use this code i get the following error: " Subscript indices must either be real positive integers or logicals."
when i dont use the (i) the info get on different sheets.
The meaning is to get a table in one sheet with all the gray values.
so for image 1 I1 the gray value in B2, image 2 I1 the gray value in b3 image 3 I1 the gray value in b4 -- and so for image 1 I2 the gray value in C2 image 2 I2 the gray value in C3 image 3 I2 the gray value in C4 ETC
Thorsten
Thorsten 2015 年 9 月 22 日
編集済み: Thorsten 2015 年 9 月 22 日
This makes more sense. So in the for loop, use
data(i,:) = [mean2(I1) mean2(I2) mean2(I3)];
And outside the loop write the data to the xls file
xlswrite(filenamexlsx,data);
N/A
N/A 2015 年 9 月 22 日
I think I found the sollution! It seems to work right now for this part!!
Thank you for your help! :)

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 9 月 22 日

0 投票

Save all of the values in a cell array. At the end of the loop write out the cell array

カテゴリ

ヘルプ センター および File ExchangeData Import from MATLAB についてさらに検索

質問済み:

N/A
2015 年 9 月 22 日

編集済み:

N/A
2015 年 9 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by