?? swtu.m
字號:
%輸入的為三維RGB圖
function [U,b,a,the,G]=swtu(g,n0,v,c)
g=double(g)/255;
x1=g(:,:,1);
X1=x1(:);
x2=g(:,:,2);
X2=x2(:);
x3=g(:,:,3);
X3=x3(:);
m=2;
the=0.1;
thresh=0.001;
[h,w]=size(x1);
n=h*w;
U=rand(n,c);
Y=sum(U,2);
for j=1:c
U(:,j)=U(:,j)./Y;
end
b=0;
for q=1:60
%while the>thresh
b=b+1;
U1=U;
for j=1:c
Y=U(:,j).^m;
fz1=sum(Y.*X1);
V1(j)=fz1./sum(Y);
fz2=sum(Y.*X2);
V2(j)=fz2./sum(Y);
fz3=sum(Y.*X3);
V3(j)=fz3./sum(Y);
end
%計算特征不相似性度量
for j=1:c
d1(:,j)=(abs(X1-V1(j))+abs(X2-V2(j))+abs(X3-V3(j)))/3;
end
%計算空間不相似性度量
UU=rylzcx(U,x1);%c程序
s1=sum(UU,2);
for j=1:c
d2(:,j)=1-(UU(:,j)./s1);
end
%總體不相似性度量
a=0.2/(0.1+exp(-(b-n0)/v));
d=d1+0.2*d2;
%更新隸屬度矩陣
U=gengxin(d); %c程序
[P,I1]=max(U1,[],2);
[P,I]=max(U,[],2);
R=(I-I1);
the=sum(R~=0)/(h*w);
end
%劃分類別
[P,I2]=max(U,[],2);
G=reshape(I2,h,w);
figure,imshow(G,[]);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -