资源简介
么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代码.zip
- 三周期极小曲面建模代码
- 直方图均衡化Matlab源代码
- 人造地震动matlab源代码
- 混合差分遗传进化算法代码(matlab)
- 神经网络用于模式识别及MATLAB源代码
- 差分进化算法的Matlab代码,可运行
- matlab支持向量机源代码
- 一维激波管问题upwind格式matlab代码
- 自组织特征映射神经网络matlab
- DEMATEL代码
- 肤色模型人脸识别matlab代码
- 用matlab生成正弦表程序.m文件
- 单神经元自适应PID代码
- 多元回归的交叉验证程序 可供做预测
- 基于MeanShift的目标跟踪算法
- Boid集群运动无捕食者、有捕食者俩种
- 直方图均衡化 matlab 代码
- 小波去噪matlab代码
- matlab经典全集内含插值源带码B-splin
- 基于MATLAB的图像边缘检测算法实验
- 蚁群算法求解最短路径问题MATLAB代码
- RLS语音信号去噪matlab代码
- matlab偏色校正代码
- 粒子群算法源代码
- 图像处理/图像分割实验/prewitt/robert
- matlab求解平面度源代码程序fig
- 基于matlab的癌细胞的识别与定位的代
评论
共有 条评论