这个函数MATLAB 不自带,可以添加到MATLAB函数库中,file-> set path -> add with subfolder
另外一种方法就是 把statxture.m 文件添加到MATLAB的工作路径里,这样做的好处就是,随时可以取消这个路径,不影响系统的稳定性。因为有些自定义的函数,会跟MATLAB自带的函数有冲突。
function [t]=statxture(f,scale)
%STATXTURE Computes statistical measures of texture in an image.
%
%
%
%
%
%
%
%
%
%
%
%
%
%
if nargin==1
else
end
%Obtain histogram and normalize it.
p=imhist(f);
p=p./numel(f);
L=length(p);
% Compute the three moments. We need the unnormalized ones
% from function statemoments. There are in vector mu.
[v,mu]=statmoments(p,3);
%计算六个纹理特征
t(1)=mu(1);
t(2)=mu(2).^0.5;
varn=mu(2)/(L-1)^2;
t(3)=1-1/(1+varn);
t(4)=mu(3)/(L-1)^2;
t(5)=sum(p.^2);
t(6)=-sum(p.*(log2(p+eps)));
T=[t(1) t(2) t(3) t(4) t(5) t(6)]
%缩放值,默认为1
t=t.*scale;
end
function [v,unv]=statmoments(p,n)
Lp=length(p);
if (Lp~=256)&(Lp~=65536)
end
G=Lp-1;
p=p/sum(p);p=p(:);
z=0:G;
z=z./G;
m=z*p;
z=z-m;
v=zeros(1,n);
v(1)=m;
for j=2:n
end
if nargout>1
end
end