%%
offset = [1 1];
Txt1 = imread('textures\Texture 8.bmp');
glcm1 = graycomatrix(Txt1,'Offset',offset, 'NumLevels',256);
stats1 = graycoprops(glcm1, 'all')
H1 = graycomatrixEntropy(glcm1);
%%
Txt2 = imread('textures\Texture 4.bmp');
glcm2 = graycomatrix(Txt2,'Offset',offset, 'NumLevels',256);
stats2 = graycoprops(glcm2, 'all')
H2 = graycomatrixEntropy(glcm2);
%%
Txt3 = imread('textures\Lake.bmp');
glcm3 = graycomatrix(Txt3,'Offset',offset, 'NumLevels',256);
stats3 = graycoprops(glcm3, 'all')
H3 = graycomatrixEntropy(glcm3);
%%
Contrast = [stats1.Contrast;stats2.Contrast;stats3.Contrast];
Correlation = [stats1.Correlation;stats2.Correlation;stats3.Correlation];
Energy = [stats1.Energy;stats2.Energy;stats3.Energy];
Homogeneity = [stats1.Homogeneity;stats2.Homogeneity;stats3.Homogeneity];
Entropy = [H1;H2;H3]
T = table(Contrast, Homogeneity, Energy, Entropy, Correlation);
%%
figure
Variables = T.Variables;
xvalues = {'Contrast','Homogeneity','Energy', 'Entropy','Correlation'};
yvalues = {'fine','coarse','flat'};
h = heatmap(xvalues, yvalues, Variables);
h.ColorScaling = 'scaledcolumns';
%%
function H = graycomatrixEntropy(glcm)
P = glcm./sum(glcm(:));
H = sum(sum(-(P.*log2(P+eps))));
end
禹晶、肖创柏、廖庆敏《数字图像处理(面向新工科的电工电子信息基础课程系列教材)》
禹晶、肖创柏、廖庆敏《数字图像处理》资源二维码