Clear ALL;CLC;
Imagepath= ' D:\Caffe\Examples\WangYu\C2\WithAugment\Data\train_image\ ';
Images = Dir ([ImagePath, ' *.tif ']);
Picturenums = Length (Images);
Fiturenums = 8;
Gray_comatrix=zeros (picturenums,fiturenums);
Label_features=zeros (picturenums,fiturenums+1);
For i=1:picturenums I name = Images (i). Name;
I=imread ([imagepath,name]);
B=rgb2gray (I); H=graycomatrix (B, ' graylimits ', [], ' numlevels ', fiturenums, ' Offset ', [0 1;-1 1;0-1;-1-1]);% get gray-scale symbiosis matrix Stats=new_
Graycoprops (H, ' all ');
energy = []; energy= [Energy,stats.
Energy];
Energy=mean (energy);
Contrast=[]; Contrast=[contrast,stats.
Contrast];
Contrast=mean (contrast);
Correlation=[]; Correlation=[correlation,stats.
Correlation];
Correlation=mean (Correlation);
Dissimilarity=[]; Dissimilarity=[dissimilarity,stats.
Dissimilarity];
Dissimilarity=mean (dissimilarity);
Entropy=[]; Entropy=[entropy,stats.
Entropy]; Entropy=mean (Entropy);
Homogeneity=[]; Homogeneity=[homogeneity,stats.
Homogeneity];
Homogeneity=mean (homogeneity);
Mean=[]; Mean=[mean,stats.
Mean];
Mean=mean (Mean);
Variance=[]; Variance=[variance,stats.
Variance];
Variance=mean (Variance);
% Gray_comatrix (i,1) =energy;
% Gray_comatrix (i,2) =contrast;
% Gray_comatrix (i,3) =correlation;
% Gray_comatrix (i,4) =dissimilarity;
% Gray_comatrix (i,5) =entropy;
% Gray_comatrix (i,6) =homogeneity;
% Gray_comatrix (i,7) =mean;
% Gray_comatrix (i,8) =variance;
% category label if (name (1) = = ' C ') label = 1;
else label = 0;
End Label_features (i,1) = label;
Label_features (i,2) = energy;
Label_features (i,3) = contrast;
Label_features (i,4) = Correlation;
Label_features (i,5) = dissimilarity;
Label_features (i,6) = Entropy;
Label_features (i,7) = homogeneity;
Label_features (i,8) = Mean; Label_features (i,9) = VaRiance;
End% Save (' mat filename ', ' variable name ') Save (' Label_features ', ' label_features ');