资源简介
针对点云数据进行Mean shift聚类,可以通过调整聚类算法的阈值以及搜索半径,来达到不同的聚类效果,内附有示例,运行test.m即可。
代码片段和文件信息
function [CC]=Mean_shift_7171(cA)
data=c;
%mean shift 算法
[mn]=size(data);
index=1:m;
radius=10; %搜索半径设定
stopthresh=1e-3*radius; %阈值设定
visitflag=zeros(m1);%标记是否被访问
count=[];
clustern=0;
clustercenter=[];
while length(index)>0
cn=ceil((length(index)-1e-6)*rand);%随机选择一个未被标记的点,作为圆心,进行均值漂移迭代
center=data(index(cn):);
this_class=zeros(m1);%统计漂移过程中,每个点的访问频率
%步骤2、3、4、5
while 1
%计算球半径内的点集
dis=sum((repmat(centerm1)-data).^22);
radius2=radius*radius;
innerS=find(dis visitflag(innerS)=1;%在均值漂移过程中,记录已经被访问过得点
this_class(innerS)=this_class(innerS)+1;
newcenter=zeros(13);
sumweight=0;
for i=1:length(innerS)
w=exp(dis(innerS(i))/(radius*radius));
sumweight=w+sumweight;
newcenter=newcenter+w*data(innerS(i):);
end
newcenter=newcenter./sumweight;
if norm(newcenter-center) break;
end
center=newcenter;
end
%步骤6 判断是否需要合并,如果不需要则增加聚类个数1个
mergewith=0;
for i=1:clustern
betw=norm(center-clustercenter(i:));
if betw mergewith=i;
break;
end
end
if mergewith==0 %不需要合并
clustern=clustern+1;
clustercenter(clustern:)=center;
count(:clustern)=this_class;
else %合并
clustercenter(mergewith:)=0.5*(clustercenter(mergewith:)+center);
count(:mergewith)=count(:mergewith)+this_class;
end
%重新统计未被访问过的点
index=find(visitflag==0);
end%结束所有数据点访问
%绘制分类结果,仅只画出前4个类簇,可根据自己需要作调整画图。
for i=1:m
[value index]=max(count(i:));
Idx(i)=index;
end
figure(2);
plot3(A(:1)A(:2)A(:3)‘g.‘);
hold on;
for i=1:m
if Idx(i)==1;
plot3(data(i1)data(i2)data(i3)‘o‘‘MarkerEdgeColor‘‘k‘‘MarkerFaceColor‘‘y‘ ‘MarkerSize‘5);
elseif Idx(i)==2;
plot3(data(i1)data(i2)data(i3)‘o‘‘MarkerEdgeColor‘‘k‘‘MarkerFaceColor‘‘b‘ ‘MarkerSize‘5);
elseif Idx(i)==3;
plot3(data(i1)data(i2)data(i3)‘o‘‘MarkerEdgeColor‘‘k‘‘MarkerFaceColor‘‘r‘ ‘MarkerSize‘5);
elseif Idx(i)==4;
plot3(data(i1)data(i2)data(i3)‘o‘‘MarkerEdgeColor‘‘k‘‘MarkerFaceColor‘‘w‘ ‘MarkerSize‘5);
% elseif Idx(i)==5;
% plot3(data(i1)data(i2)data(i3)‘o‘‘MarkerEdgeColor‘‘k‘‘MarkerFaceColor‘‘w‘ ‘MarkerSize‘5);
% ‘
% ‘
% ‘
end
end
for k = 1:clustern
CC(k:)=[clustercenter(k1)clustercenter(k2)clustercenter(k3)];
end
OX=[5000]‘;
OY=[0500]‘;
OZ=[0050]‘;
xlabel(‘X轴‘);
ylabel(‘Y轴‘);
zlabel(‘Z轴‘);
axis equal;rotate3d on;
quiver3(000OX(1)OX(2)OX(3)‘color‘[1 0 0
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 76125 2020-05-18 13:56 Mean shift对点云聚类\A.mat
文件 3397 2020-05-18 13:58 Mean shift对点云聚类\Mean_shift_7171.m
文件 11483 2020-05-18 13:57 Mean shift对点云聚类\POINT.mat
文件 587 2020-05-18 13:52 Mean shift对点云聚类\test.m
目录 0 2020-05-18 13:53 Mean shift对点云聚类
----------- --------- ---------- ----- ----
91592 5
相关资源
- 图像去噪方法分析比较BLS GSM BM3D Non
- matlab实现三维点云三角化
- K均值聚类算法,图像处理,GUI,mat
- Matlab 三维点云 三角化
- 用matlab编写的Meanshift追踪程序
- MATLAB 三维点云重构Surface recostruction
- mean shift 目标跟踪matlab程序
- 基于K-means算法的遥感图像分类的mat
- Meanshift算法实现目标跟踪的MatLAB代码
- 基于Matlab实现的图像分割的常用算法
- meanshift分割算法的matlab实现,完整标
- matlab delaunary 三维点云三角化
- 基于高斯球的三维点云精简,matlab实
- mean shift目标跟踪matlab程序
- 四种聚类算法源代码及
- 基于Meanshift的单目标跟踪
- kmeans图像分类
- meanshift图像平滑matlab实现
- matlab mean shift EDISON Wrapper 图像分割
- 路标识别与提取采用聚类方法C-means
- MeanShift算法详解以及matlab源码
- KMeans+BOF实现图像检索Matlab
- 基于Meanshift的单目标跟踪算法matlab及
- mean shift算法matlab源代码及演示图片
- MeanShift均值漂移目标追踪算法源码
- 模式识别 改进的K-Means++算法 实现模式
- k-means聚类MATLAB的基本代码
- 数据曲线K_means聚类分析
- k-means数据聚类实验报告 MATLAB详细代码
- k-means聚类分析
评论
共有 条评论