资源简介
么anshift聚类算法的matlab实现,以及2维演示程序。很好很强大的代码学习资料!

代码片段和文件信息
function [clustCentdata2clustercluster2dataCell] = MeanShiftCluster(dataPtsbandWidthplotFlag);
%perform MeanShift Clustering of data using a flat kernel
%
% ---INPUT---
% dataPts - input data (numDim x numPts)
% bandWidth - is bandwidth parameter (scalar)
% plotFlag - display output if 2 or 3 D (logical)
% ---OUTPUT---
% clustCent - is locations of cluster centers (numDim x numClust)
% data2cluster - for every data point which cluster it belongs to (numPts)
% cluster2dataCell - for every cluster which points are in it (numClust)
%
% Bryan Feldman 02/24/06
% MeanShift first appears in
% K. Funkunaga and L.D. Hosteler “The Estimation of the Gradient of a
% Density Function with Applications in Pattern Recognition“
%*** Check input ****
if nargin < 2
error(‘no bandwidth specified‘)
end
if nargin < 3
plotFlag = true;
plotFlag = false;
end
%**** Initialize stuff ***
[numDimnumPts] = size(dataPts);
numClust = 0;
bandSq = bandWidth^2;
initPtInds = 1:numPts;
maxPos = max(dataPts[]2); %biggest size in each dimension
minPos = min(dataPts[]2); %smallest size in each dimension
boundBox = maxPos-minPos; %bounding box size
sizeSpace = norm(boundBox); %indicator of size of data space
stopThresh = 1e-3*bandWidth; %when mean has converged
clustCent = []; %center of clust
beenVisitedFlag = zeros(1numPts‘uint8‘); %track if a points been seen already
numInitPts = numPts; %number of points to posibaly use as initilization points
clusterVotes = zeros(1numPts‘uint16‘); %used to resolve conflicts on cluster membership
while numInitPts
tempInd = ceil( (numInitPts-1e-6)*rand); %pick a random seed point
stInd = initPtInds(tempInd); %use this point as start of mean
myMean = dataPts(:stInd); % intilize mean to this points location
myMembers = []; % points that will get added to this cluster
thisClusterVotes = zeros(1numPts‘uint16‘); %used to resolve conflicts on cluster membership
while 1 %loop untill convergence
sqDistToAll = sum((repmat(myMean1numPts) - dataPts).^2); %dist squared from mean to all points still active
inInds = find(sqDistToAll < bandSq); %points within bandWidth
thisClusterVotes(inInds) = thisClusterVotes(inInds)+1; %add a vote for all the in points belonging to this cluster
myOldMean = myMean; %save the old mean
myMean = mean(dataPts(
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5815 2006-02-26 16:59 MeanShiftCluster.m
文件 996 2006-02-26 16:53 testMeanShift.m
- 上一篇:利用matlab对瑞利衰落信道仿真
- 下一篇:matlab预处理共轭梯度法
相关资源
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 《MATLAB 智能算法超级学习手册》-程序
- 读取txt文件内容matlab代码实现
- 算术编码解码matlab源代码
- OFDM系统MATLAB仿真代码
- 图像小波变换MatLab源代码
- 细胞图像分割matlab代码
- 基于MP的时频分析MATLAB代码
- 工程优化问题的Matlab实现代码
- WCDMA matlab代码
- 数字图像处理radon matlab变换算法代码
- 数字信号处理 理论算法与实现 胡广书
- 激光谐振腔课程设计(matlab)exe及源
- 基于harris算法的角点检测matlab原代码
- 北邮Matlab实验报告和代码
- 图像降噪Matlab代码
- matlab人脸识别和特征提取
- 圣诞树(matlab代码)
- 心音信号处理分析(附matlab代码)
- Pattern Recognition and Machine Learning(高清
- 均值滤波和FFT频谱分析Matlab代码
- 《MATLAB扩展编程》代码
- 多目标跟踪 论文+代码
- 欧拉放大论文及matlab代码
- 蚁群算法论文+源代码
- GPS信号的码捕获matlab代码.7z
- 一维光子晶体MATLAB仿真代码吸收率折
- matlab读取SP3文件
- 手把手教你学DSP--基于TMS320C55x光盘 含
评论
共有 条评论