matlab meanshift
来源:互联网 发布:linux黑客大曝光 pdf 编辑:程序博客网 时间:2024/05/02 01:14
用MATLAB 编写的meanshift 寻找聚类中心的程序 有些简陋
%% mean shift%% 产生随机点x1 = 30 + sqrt(9) * randn(1,100);y1 = 30 +sqrt(9) * randn(1,100);x2 =20+sqrt(7) * randn(1,100);y2 =20+sqrt(7) * randn(1,100);x3 =10+sqrt(6) * randn(1,100);y3 =40+sqrt(6) * randn(1,100);x=[x1 x2 x3];y=[y1 y2 y3];h =5;pointx =[x(1),y(1)];points=[x' y'];%% %% ddd =size(points);centers=zeros(10,2);count =1;for i=1:ddd(1); pointx =points(i,:); flag=0; while(1) [number,mh]=FindPoint(pointx,points,h);%返回漂移向量mh。 if sqrt(mh(1)^2+mh(2)^2)<0.001 break; end pointx=pointx+mh; end if count==1 tempcenter=centers(count,:); else tempcenter=centers(count-1,:); end if sqrt((pointx(1)-tempcenter(1))^2+(pointx(2)-tempcenter(2))^2)>5 for ii=1:count tep =centers(ii,:); if sqrt((tep(1)-pointx(1))^2+(tep(2)-pointx(2))^2)<1 flag=1; break; end end if flag==0 centers(count,:)=pointx; count=count+1; end endendscatter(x,y,3,'filled');axis([0 50 0 50]);hold onscatter(centers(:,1),centers(:,2),5,[1 0 0],'filled');
FindPoint求出均值漂移向量
function [ number,mh] = FindPoint( pointx,points,radis )%FINDPOINT Summary of this function goes here% Detailed explanation goes here a=size(points); num=0; sum=[0,0]; total =a(1); for i=1:total temppoint =points(i,:); r=sqrt((pointx(1)-temppoint(1))*(pointx(1)-temppoint(1))+(pointx(2)-temppoint(2))*(pointx(2)-temppoint(2))); if(r<=radis) num=num+1; sum=sum+[temppoint(1)-pointx(1),temppoint(2)-pointx(2)]; end end number=num; mh=sum/num;end
效果图:
0 0
- matlab meanshift
- matlab——meanshift
- MeanShift运动目标跟踪 matlab程序
- MeanShift运动目标跟踪 matlab程序
- MeanShift运动目标跟踪 matlab程序
- MeanShift运动目标跟踪 matlab程序
- Meanshift
- meanShift
- Meanshift
- Meanshift
- meanshift
- meanshift
- matlab练习程序(meanshift图像聚类)
- matlab练习程序(meanshift图像聚类)
- matlab练习程序(meanshift图像聚类)
- Matlab实现meanshift算法,目标跟踪代码实现
- MeanShift代码
- MeanShift聚类
- live555源代码概述
- 一个程序的奋斗历程
- Struts2高级
- iOS Versions第一次初始化
- 在ORCAD 的原理图中提取元件到库中
- matlab meanshift
- 利用jlink command 烧写uboot到mini2440 nand flash方法
- HTML语言中TR、TH和TD有什么区别?
- sort函数的用法
- 商务部:快捷支付限额影响网购便捷性 不利于促进消费
- ubuntu 常用命令
- [android ui]官方侧滑菜单控件Navigation Drawer
- 省市县三级联动
- UVA10099- The Tourist Guide