Is it possible to increment the excel sheet value each time so tat at the end of run
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Subha
el 25 de Dic. de 2013
Comentada: Subha
el 25 de Dic. de 2013
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 comentarios
Respuesta aceptada
Walter Roberson
el 25 de Dic. de 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')
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!