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

조회 수: 1 (최근 30일)
hp
hp 2017년 7월 3일
댓글: hp 2017년 7월 5일
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.

채택된 답변

KSSV
KSSV 2017년 7월 3일
Use this:
writetable(struct2table(I3), 'glcmfeatures.xlsx')
  댓글 수: 9
hp
hp 2017년 7월 5일
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 2017년 7월 5일
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) ;

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by