I am doing a feature extraction using glcm method. The glcm output are in 'struct' type, while i need the output in double type.
So, I've tried to convert it using several code showed below.
srcFile = dir('D:\1. Thesis FINISH!!!\*.png');
fetrain1 = [];
for b = 1:length(srcFile)
file_name = strcat('D:\1. Thesis FINISH!!!\',srcFile(b).name);
B = imread(file_name);
[gl] = glcm (B);
[gl] = struct2cell (gl);
[gl] = cell2mat (gl);
% [fiturtrain] = structfun(@double, gl, 'uniformoutput', 0);
% [fiturtrain] = double (gl);
[fiturtrain] = cell2mat (gl);
fetrain1 = [fetrain1 fiturtrain];
% vectorname = strcat(file_name,'_array.mat');
end
save ('fetrain1.mat','fetrain1');
But, the code give me 'complex double' type. I don't know why?
I need to convert fetrain1 from 'complex double' type into 'double' type, so I can use the variable for the next step. Or another way to covert 'struct' exactly to 'double' type.
Any suggestion would be very appreciated. Thank you.

4 件のコメント

Anggerik aida
Anggerik aida 2017 年 4 月 19 日
hi..do you have the solution for this problem? because i also need to solve this problem so that i can use as input for svm classifier..kindly help me
Andrew Newell
Andrew Newell 2017 年 4 月 19 日
編集済み: Andrew Newell 2017 年 4 月 19 日
A more detailed version of this question can be found at the Stack Exchange.
Megha
Megha 2017 年 7 月 10 日
It would be good enough to go with real(data) which could be real(fetrain1) in your case.
Hope this helps!
Walter Roberson
Walter Roberson 2017 年 9 月 18 日
Lin Li comments to Megha:
It helps to me. Thanks.

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

回答 (2 件)

Andrew Newell
Andrew Newell 2017 年 4 月 19 日

0 投票

Judging by the discussion in the Stack Exchange, it seems likely that you can get what you want by replacing most of the code after B = imread(file_name) by the following:
imG = rgb2gray(B);
% create gray-level co-occurrence matrix from image
gimg = graycomatrix(imG);
% extract properties of gray-level co-occurrence matrix
stats = graycoprops(gimg, 'all');
features = [stats.Energy stats.Homogeneity stats.Correlation stats.Contrast];
Then features for multiple images can be assembled into a double-precision matrix, if desired. It's hard to tell what ana ain was trying to do.
fengwei wang
fengwei wang 2018 年 10 月 9 日

0 投票

Hi,Ana ain. Now I have encountered the same problem as you. Have you solved it yet? If it is solved, can you tell me? Thanks!!

カテゴリ

ヘルプ センター および File Exchange で Data Type Conversion についてさらに検索

質問済み:

2016 年 5 月 24 日

回答済み:

2018 年 10 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by