近邻传播算法 matlab 代码,用Afinity Propagation(AP)近邻传播算法如何提取曲面边界...

已结贴√

问题点数:20 回复次数:2

ca56232b3bbedf9a539d07f37fffb99a.gif

3144d8b7615c79d9f638db40d5689d26.gif

a218af6549b45ee526caf607ebff1358.gif

0f8df0e29816ae721419de940fb833d1.gif

用Afinity Propagation(AP)近邻传播算法如何提取曲面边界

我现在用K-means算法已经求得了聚类的中心点,之前我是用V图的方法实现的,现在想用AP聚类算法提取出曲面的边界,我只是把点提取出来了没有出现边界,要如何实现呢?如果可以用其他的算法实现也可以。请各位赐教,不胜感激!!!(以下是我前部分的程序)

clear;clc;

syms u v;

x=-40+35*v+5*v*v;

y=-58*u+18*u*u;

z=6*(u*u*v*v+u*u*v)-4*u*v*v+34*u*u+4*v*v-14*u*v-50*u+25*v+6;

dxdu=diff(x,u,1);

dxdv=diff(x,v,1);

dydu=diff(y,u,1);

dydv=diff(y,v,1);

dzdu=diff(z,u,1);

dzdv=diff(z,v,1);

d2xdu2=diff(x,u,2);

d2xdv2=diff(x,v,2);

d2ydu2=diff(y,u,2);

d2ydv2=diff(y,v,2);

d2zdu2=diff(z,u,2);

d2zdv2=diff(z,v,2);

dsdu=dxdu*dxdu+dydu*dydu+dzdu*dzdu;

dsdv=dxdv*dxdv+dydv*dydv+dzdv*dzdv;

d2sdu2=diff(dsdu,u,1);

d2sdv2=diff(dsdv,v,1);

d2sdudv=diff(dsdu,v,1);

E=dsdu*dsdu;

F=dsdu*dsdv;

G=dsdv*dsdv;

L=d2sdu2;

M=d2sdudv;

N=d2sdv2;

E=inline(vectorize(E));

F=inline(vectorize(F));

G=inline(vectorize(G));

L=inline(vectorize(L));

M=inline(vectorize(M));

N=inline(vectorize(N));

pointer_A=0;

pointer_B=0;

pointer_C=0;

pointer_X=0;

pointer_Y=0;

pointer_Z=0;

for a=0:0.125:1

for b=0:0.125:1

E_cal=E(a,b);

F_cal=F(a,b);

G_cal=G(a,b);

L_cal=L(a,b);

M_cal=M(a,b);

N_cal=N(a,b);

K=(L_cal.*N_cal-M_cal.^2)./(E_cal.*G_cal-F_cal.^2);

H=(E_cal.*N_cal-2.*F_cal.*M_cal+G_cal.*L_cal)./(E_cal.*G_cal-F_cal.^2)/2;

if K>0&H>0;

pointer_A=pointer_A+1;

A(pointer_A, 1)=a;

A(pointer_A, 2)=b;

elseif K>0&H<0;

pointer_B=pointer_B+1;

B(pointer_B, 1)=a;

B(pointer_B, 2)=b;

elseif  K==0&H>0;

pointer_C=pointer_C+1;

C(pointer_C, 1)=a;

C(pointer_C, 2)=b;

elseif  K==0&H==0 ;

pointer_X=pointer_X+1;

X(pointer_X, 1)=a;

X(pointer_X, 2)=b;

elseif  K==0&H<0 ;

pointer_Y=pointer_Y+1;

Y(pointer_Y, 1)=a;

Y(pointer_Y, 2)=b;

elseif  K<0 ;

pointer_Z=pointer_Z+1;

Z(pointer_Z, 1)=a;

Z(pointer_Z, 2)=b;

end

end

end

if pointer_A>0;

opts = statset('Display','final');

[Idx,Ctrs_A,SumD,D] = kmeans(A,3,'Replicates',3,'Options',opts);

Ctrs_A ;

else

Ctrs_A=[];

end

if pointer_B>0;

opts = statset('Display','final');

[Idx,Ctrs_B,SumD,D] = kmeans(B,3,'Replicates',3,'Options',opts);

Ctrs_B ;

else

Ctrs_B=[];

end

if pointer_C>0;

opts = statset('Display','final');

[Idx,Ctrs_C,SumD,D] = kmeans(C,3,'Replicates',3,'Options',opts);

Ctrs_C ;

else

Ctrs_C=[];

end

if pointer_X>0 ;

opts = statset('Display','final');

[Idx,Ctrs_X,SumD,D] = kmeans(X,3,'Replicates',3,'Options',opts);

Ctrs_X ;

else

Ctrs_X=[];

end

if pointer_Y>0 ;

opts = statset('Display','final');

[Idx,Ctrs_Y,SumD,D] = kmeans(Y,3,'Replicates',3,'Options',opts);

Ctrs_Y;

else

Ctrs_Y=[];

end

if pointer_Z>0;

opts = statset('Display','final');

[Idx,Ctrs_Z,SumD,D] = kmeans(Z,3,'Replicates',3,'Options',opts);

Ctrs_Z ;

else

Ctrs_Z=[];

end

SumD ;

搜索更多相关主题的帖子:

不胜感激 如何 中心

你可能感兴趣的:(近邻传播算法,matlab,代码)