MATLAB提取纹理特征的简化方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
clear all,clc;
gray = imread('circuit.tif');
offsets = [0 1;-1 1;-1 0;-1 -1];
[glcm,SI] = graycomatrix(gray,'GrayLimits',[],'NumLevels',16,'Of',offsets);
subplot(1,3,1),imshow(gray);
subplot(1,3,2),imhist(gray);
%-----------------------------------------------------------
% 查看灰度级压缩之后的图像
%-----------------------------------------------------------
subplot(1,3,3),imshow(SI,[0,15]);
%使用imshow()显示不同灰度级时,要使用imshow(SI,[low,high])格式,否则无法正确显示图片内容。
%对于uint8类型图像默认显示范围取【0,255】,对于double类型图像默认显示范围【0,1】
%-----------------------------------------------------------
% 求出四个方向上的灰度共生矩阵特征参量
%-----------------------------------------------------------
stats = graycoprops(glcm,{'contrast','homogeneity','Energy','Correlation'});

显示图像及灰度频率直方图:

Snipaste_2024-05-06_20-33-39.png

图像灰度级压缩后的图像:

Snipaste_2024-05-06_20-33-59.png

stats中保存:’contrast’,’homogeneity’,’Energy’,’Correlation’:

Snipaste_2024-05-06_20-35-36.png