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; %对比度
利用matlab自带函数graycoprops 实现基于共生矩阵的遥感图像纹理特征分析
最新推荐文章于 2021-04-02 03:34:25 发布