close all;clear all;clc;
I = imread('yaogan2.jpg');
HSV = rgb2hsv(I);
Hgray = rgb2gray(HSV);
% 计算64位灰度共生矩阵
glcmsl = graycomatrix(Hgray,'numlevels',64,'offset',[0 1;-1 1;-1 0;-1 -1]);
% 纹理特征统计,包括对比度、相关性、熵、平稳度、二阶矩(能量)
stats = graycoprops(glcmsl,{'contrast','correlation','energy','homogeneity'});
ga1 = glcmsl(:,:,1); %0°
ga2 = glcmsl(:,:,2); %45°
ga3 = glcmsl(:,:,3); %90°
ga4 = glcmsl(:,:,4); %135°
energya1 = 0;energya2=0;energya3=0;energya4=0;
for i=1:64
for j=1:64
energya1=energya1+sum(ga1(i,j)^2);
energya2=energya2+sum(ga2(i,j)^2);
energya3=energya3+sum(ga3(i,j)^2);
energya4=energya4+sum(ga4(i,j)^2);
j=j+1;
end
i=i+1;
end
s1=0;s2=0;s3=0;s4=0;s5=0;
for m=1:4
s1=stats.Contrast(1,m)+s1; %对比度
m=m+1;
end
for m=1:4
s2=stats.Correlation(1,m)+s2; %相关性
m=m+1;
end
for m=1:4
s3=stats.Energy(1,m)+s3; %熵
m=m+1;
end
for m=1:4
s4=stats.Homogeneity(1,m)+s4; %平稳度
m=m+1;
end
s5 = 0.000001*(energya1+energya2+energya3+energya4); %二阶矩(能量)
对比度 | 相关性 | 熵 | 平稳度 | 二阶矩(能量) | |
山脉遥感(yaogan1.jpg) | 1.5356e+02 | 3.0695 | 0.0090 | 1.3864 | 6.8678e+02 |
城镇遥感(yaogan2.jpg) | 65.2117 | 2.6387 | 0.0458 | 2.1418 | 2.3649e+03 |
山脉遥感对比度明显高于城镇,城镇遥感的平稳度和能量明显大于山脉。
来源:博客园
作者:我坚信阳光灿烂
链接:https://www.cnblogs.com/wojianxin/p/11430252.html