《数字图像处理(面向新工科的电工电子信息基础课程系列教材)》例10-8

在这里插入图片描述
在这里插入图片描述

%%
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

禹晶、肖创柏、廖庆敏《数字图像处理(面向新工科的电工电子信息基础课程系列教材)》
禹晶、肖创柏、廖庆敏《数字图像处理》资源二维码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值