Filter löschen
Filter löschen

matlab code to store GLCM features into an Excel sheet..

1 Ansicht (letzte 30 Tage)
hp
hp am 3 Jul. 2017
Kommentiert: hp am 5 Jul. 2017
here i have a code after reading an image ... it is resized and GLCM is calculated .. this GLCM features are calculated for folder of images... and I need this to be stored in an excel ... the code i used is:
RGB=imresize(image,[256 256]);
I=rgb2gray(RGB);
I2=graycomatrix(I);
I3=graycoprops(I2);
usecel{1}=I3;
file1 = 'C:\Program Files\hemaMATLAB\R2007b\work\glcmfeatures.xlsx';
xlswrite(file1,usecel{1});
but the below code is giving an error like: ??? Error using ==> xlswrite at 114 Input data must be a numeric, cell, or logical array.
please tell me how to write a matlab code to store GLCM features to store in an Excel sheet.... I need this for comparison.

Akzeptierte Antwort

KSSV
KSSV am 3 Jul. 2017
Use this:
writetable(struct2table(I3), 'glcmfeatures.xlsx')
  9 Kommentare
hp
hp am 5 Jul. 2017
I tried the code below: dir_in = 'C:\Program Files\hemaMATLAB\R2007b\work\capinput\';
dir_out = 'C:\Program Files\hemaMATLAB\R2007b\work\output\';
file_ext = 'jpg';
listing = dir(strcat(dir_in,'i*.',file_ext));
file_names = {listing.name};
num_pages = length(file_names);
gdata = cell(num_pages,1);
for imgNum = 1 : num_pages
fprintf('Computing Texture..... %d...\n', imgNum);
image = rgb2gray(imread(strcat(dir_in,file_names{imgNum})));
RGB=imresize(I,[256 256]);
I=rgb2gray(RGB);
I2=graycomatrix(I);
I3=graycoprops(I2);
P = [fieldnames(I3),struct2cell(I3)] ;
P = [fieldnames(I3) struct2cell(I3)] ;
% append more values in loop
Pcell = cell(6,4) ;
Pcell(1:2,:) = P' ;
for i = 3:6
Pcell(i,:) = num2cell(rand(1,4)) ;
end
xlswrite('myfile.xlsx',Pcell) ;
end
and the above code is giving error as follows:
Processing an Image: 1
??? Error using ==> rgb2gray>parse_inputs at 82
MAP must be a m x 3 array.
Error in ==> rgb2gray at 35
X = parse_inputs(varargin{:});
Error in ==> texturetest1 at 21
I=rgb2gray(map);
??? 4lines_of_feature_into_xlsheet |
Error: Unexpected MATLAB expression.
hp
hp am 5 Jul. 2017
sorry the above code is not corrected ... here is the code below ... which is giving error:
dir_in = 'C:\Program Files\hemaMATLAB\R2007b\work\capinput\';
dir_out = 'C:\Program Files\hemaMATLAB\R2007b\work\output\';
file_ext = 'jpg';
listing = dir(strcat(dir_in,'i*.',file_ext));
file_names = {listing.name};
num_pages = length(file_names);
for imgNum = 1 : num_pages
fprintf('Computing Texture..... %d...\n', imgNum);
image = rgb2gray(imread(strcat(dir_in,file_names{imgNum})));
I=imresize(image,[256 256]);
I2=graycomatrix(I);
I3=graycoprops(I2);
P = [fieldnames(I3),struct2cell(I3)] ;
P = [fieldnames(I3) struct2cell(I3)] ;
% append more values in loop
Pcell = cell(6,4) ;
Pcell(1:2,:) = P' ;
for i = 3:6
Pcell(i,:) = num2cell(rand(1,4)) ;
end
xlswrite('myfile.xlsx',Pcell) ;
end
and the error is:
Computing Texture..... 1...
??? Index exceeds matrix dimensions.
Error in ==> fourfeatureExcelsheet at 21
Pcell = cell(6,4) ;

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by