基于复杂网络的纹理分析与分类
文献:Texture analysis and classification: A complex network-based approach
文献链接
Matlab复现代码
Pixel_value.m
function [I_1,x,y]=Pixel_value(I)
I=double(I);
[x,y,z]=size(I);
IR=I(:,:,1);I_R=reshape(IR,x*y,1);
g=[];
for i=1:x
x_co=linspace(i,i,x);y_co=linspace(1,x,x);
X=x_co';Y=y_co';XY=[X,Y];
g=[g;XY];
end
I_1=[g,I_R];
end
Weight_matrix.m
%算权值矩阵
function W=Weight_matrix(pixel,RADIUS,T,xy) %像素、半径、xy
R=2*RADIUS^2; %权值
L=(RADIUS^2/max(pixel(:,3))); %权值
w=zeros(xy,xy);
X=[pixel(:,1) pixel(:,2)];
D=pdist(X);
z=triu(squareform(D));
[p0,p1]=find(z>0&z<=RADIUS);
R_d=[p0 p1];
for i=1:length(p0)
t=R_d(i,:);
k1=t(:,1);r1=pixel(k1,:);z1=r1(:,3); %像素1
k2=t(:,2);r2=pixel(k2,:);z2=r2(:,3); %像素2
h=abs(z1-z2);
% w(k1,k2)=(h*L+(z(k1,k2))^2)/R;
w(k1,k2)=(abs(h)+z(k1,k2))/R;
if w(k1,k2)>T
w(k1,k2)=0;
end
end
W=w+w';
end
Degree_matrix.m
addpath(genpath('./func'));
RADIUS=3;T=3;
a=imread('T01_36.jpg');%读入图片
b=imresize(a,[96,96]);
[pixel,x,y]=Pixel_value(b);xy=x*y;
W=Weight_matrix(pixel,RADIUS,T,xy);
graph_edges=graph(W);
Deg=degree(graph_edges);
D_matrix=reshape(Deg,x,y);
I=mat2gray(D_matrix);
figure(1);
histogram(D_matrix);
figure(2)
subplot(1,2,1);
imshow(b);
subplot(1,2,2);
I=mat2gray(D_matrix);
imshow(I);
% imwrite(I,'T04_40.jpg');
实验效果