Is it possible to increment the excel sheet value each time so tat at the end of run
3 views (last 30 days)
Show older comments
This is my simple pgm to calcualte glcm features for 10 images... for all the 10 images the feature value should be written in excel sheet, i have done with xlswrite option. the problem i have is only the feature value of last image is written in excel sheet..
is it possible to increment the excel sheet value each time so tat at the end of run.. all features for 10 images is stored in excel sheet????
like.. Image1 - fea1 fea2 ..... fea16 Image2 - fea1 fea2 ..... fea16
numImgs = 10;
for imgNum = 1 : numImgs
fprintf('Computing Texture..... %d...\n', imgNum);
img = imread(sprintf('samplepics/%d.jpg',imgNum)); %its a gray scale image
offsets0 = [0 1;-1 1;-1 0;-1 -1];
glcms = graycomatrix(i,'Offset',offsets0);
stats = graycoprops(glcms, {'contrast','homogeneity','Energy','Correlation'});
g1=stats.Contrast;
g2=stats.Homogeneity;
g3=stats.Energy;
g4=stats.Correlation;
gg=struct2cell(stats); % toally 16 features
xlswrite('feature.xls',[g1 g2 g3 g4],'Sheet3','b2:q2')
end
Thanks in advance
0 Comments
Accepted Answer
Walter Roberson
on 25 Dec 2013
You would need to keep track of it yourself and change the offset. As you are specifying the sheet name you can do it with just the starting letter and column.
Easier would be to store everything and write it once.
gdata = cell(numImgs,1);
for imgNum = 1 : numImgs
fprintf('Computing Texture..... %d...\n', imgNum);
img = imread(sprintf('samplepics/%d.jpg',imgNum)); %its a gray scale image
offsets0 = [0 1;-1 1;-1 0;-1 -1];
glcms = graycomatrix(i,'Offset',offsets0);
stats = graycoprops(glcms, {'contrast','homogeneity','Energy','Correlation'});
g1=stats.Contrast;
g2=stats.Homogeneity;
g3=stats.Energy;
g4=stats.Correlation;
gg=struct2cell(stats); % toally 16 features -> not used?
gdata{imgNum} = [g1 g2 g3 g4];
end
xlswrite('feature.xls', gdata, 'Sheet3','b2')
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!