No BSD License  

Highlights from
Mean Shift Clustering

4.05556

4.1 | 18 ratings Rate this file 223 Downloads (last 30 days) File Size: 2.66 KB File ID: #10161

Mean Shift Clustering

by Bart Finkston

 

26 Feb 2006 (Updated 27 Feb 2006)

Cluster data by using the Mean Shift Algorithm

| Watch this File

File Information
Description

Clusters data using the Mean Shift Algorithm. testMeanShift shows an example in 2-D. Set plotFlag to true to visualize iterations.

MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (33)
05 Apr 2006 Yang wool

??? Subscripted assignment dimension mismatch.

Error in ==> D:\¹êÅç\MeanShift\MeanShiftCluster.m
On line 99 ==> clusterVotes(numClust,:) = thisClusterVotes;

Error in ==> D:\¹êÅç\MeanShift\testMeanShift.m
On line 25 ==> [clustCent,point2cluster,clustMembsCell] = MeanShiftCluster(x,bandwidth);

14 May 2006 yang Min

very good

29 May 2006 orazio gambino

Hi guys,

I changed the following lines into MeanShiftCluster.m and now it works:

40: beenVisitedFlag = zeros(1,numPts);
42: clusterVotes = zeros(1,numPts);
51: thisClusterVotes = zeros(1,numPts);

Bye...

20 Jul 2006 Abhijeet Jadhav

How to use it for image?

01 Sep 2006 Hanh Vu

Hello every body
I have to use the mean-shift algorithm for finding the modes of a
image histogram. is there anyone that have an M-file to do this?
Thanks in advance.

14 Oct 2006 Ning J.

see D. Comaniciu PH.D Thesis about clustering or applying mean shift to image!

13 Nov 2006 hosung han

thanks

27 Nov 2006 satria gunawan

i too not undestand to used to image, there are some body help me?

03 Jan 2007 JW Lee

Can anyone provide some help for me on how to use this clustering algorithm on images?

05 Jan 2007 Ming Liu

The code is good, while more examples can further improve the quality.

17 Mar 2007 praisan padungweang

clustering algorithm on images?
You may prepare the data in 1D(gray scale), 3D (RGB or x,y,I;in gray scale) or 5D (x,y,R,G,B) then go with mean shift.

22 Mar 2007 Patson patrick

I would like to subscribe the algorithm mean shift .
                  Tank you

18 Jun 2007 Kim GH

It's good but some problem occures when running on the matlab ver 6.5.
To aboide this modify like that
"zeros(1,numPts,'unit8');" -> "zeros(1,numPts);"

25 Dec 2007 jaya priya

i want to do it for color image segmentation how to do pls help me

27 Mar 2008 Tac Charles

Thank you

24 Apr 2008 Rob Barton

It is good base code:

However I believe that the author is using something closer to a nadaraya-watson estimator (When he takes the:

Mean = mean(dataPts:,inInds),2);

He states he is using a 'flat' or epanechnikov kernal and the computation is different:

See: Dorin Comaniciu "Mean Shift: A Robust Approach Toward Feature Space Analysis" IEEE Transactions on pattern analysis and machine intelligence, Vol. 24, No. 5, May 2002.

By altering this and making a few other minor edits this is excellent code to start from to customize to the users requirements.

the computation of 'sqDistToAll = sum(...)' makes the assumption that the user passes more than a 1D data... so if you passed just gray levels of an image in a 1D array the code will crash, however if you passed a LUV image, (3 elements per pixel) it would work. alternately you can pad the input data with a redundant row or alter the code to check for a single row input and perform the slightly modified but same computation.

Thanks.

22 May 2008 Daniel Carlton

Rob, by padding you mean adding a row containing only zeros ? Indeed using a 1D vector (a grayscale image vectorized) the code crashes as you say.

What does the "bandwitdh" parameter stand for ? Is it the window size ?

Thank you

12 Jun 2008 Wahyu Caesar

can I use to vibration data.
please send the answer to my email :
caesarwahyu@yahoo.com

22 Jul 2008 Yun Yongsheng

I have downloaded this code, and tested in my pc'matlab6.5 R13. But there are still two errors happened. The error is reported as " The Error in ==> C:\MATLAB6p5\work\RectifKitU\MeanShift\MeanShiftCluster.m
On line 99 ==> clusterVotes(numClust,:) = thisClusterVotes; "
??? Subscripted assignment dimension mismatch."

   I don't know how to solve this problem for the code. Could any one kind help me?

17 Oct 2008 brais martinez

good code and working straight away but there is no option to set weights to the clustered points

also a brief help file would be useful (to describe parameters and so on)

28 Jan 2009 Shai

For image you have
http://www.wisdom.weizmann.ac.il/~bagon/matlab.html

26 Apr 2009 Sebastien Paris

Well done!

01 May 2009 Luis Mont Blanc

I see this: http://www.wisdom.weizmann.ac.il/~bagon/matlab.html
But i don't understand how to use it.
How can i use the 4th argument of the function?

Can you please write a sample code of how to use it?

Thank you

11 May 2009 Shai

Luis,
type
>> doc edison_wrapper
and you'll get a description of the various parameters and default values.

13 Jun 2009 Anton Kylling

I get an unhandled exception using edison_wrapper. Anyone else experiencing this?

  MATLAB Version: 7.7.0.471 (R2008b)
  Operating System: Microsoft Windows Vista
  Window System: Version 6.0 (Build 6002: Service Pack 2)
  Processor ID: x86 Family 6 Model 7 Stepping 6, GenuineIntel
  Virtual Machine: Java 1.6.0_04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode
  Default Encoding: windows-1252

Vista x64 might be the problem, but I have recompiled the wrapper.

Any help is appreciated. Thanks in advance.

07 Oct 2009 Anton Kylling

Problem solved :)

08 Jan 2010 Fuat Cogun  
25 May 2010 Harrison Woods

Very good code, thank u ,guy!

21 Jul 2010 Tali

In order to Bart's code on 1D dim data a small change should be made:

sqDistToAll = sum((repmat(myMean,1,numPts) - dataPts).^2,1);

11 Nov 2010 Nam

Guys, is there any code for high dimensional data? This code doesnt work for D is greater than 2. Thanks.

06 Jul 2011 Peter K  
06 Jul 2011 Peter K

This is great code! It's very easy to read and taught me a lot about mean shift.

I found that the runtime was decreased on my machine and data by replacing the lines:

sqDistToAll = sum((repmat(myMean,1,numPts) - dataPts).^2);
and
beenVisitedFlag(myMembers) = 1;

with:

sqDistToAll = sum(bsxfun(@minus,myMean,dataPts).^2);
and
beenVisitedFlag(inInds) = 1;

respectively.

Thanks for the code!

22 Dec 2011 Punit Rathore

Can anybody give me the this code for colour image segmentation??

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
statistics Bart Finkston 22 Oct 2008 08:16:52
probability Bart Finkston 22 Oct 2008 08:16:52
clustering Bart Finkston 22 Oct 2008 08:16:52
mean shift Bart Finkston 22 Oct 2008 08:16:52
animation Cristina McIntire 07 Nov 2008 12:55:38
clustering Aviv Hurvitz 11 Mar 2009 03:36:22
clustering antonio ferraz 23 Mar 2009 11:55:08
animation Moshe 29 Jun 2010 05:55:36
clustering Moshe 29 Jun 2010 05:55:38
mean shift Moshe 29 Jun 2010 05:55:40
mean shift mohan meena 22 Aug 2010 13:11:06
mean shift Danilson Gagar 15 Feb 2011 04:08:16
animation Aaron cheng 02 May 2011 02:09:15
animation Siamak Safarzadegan Gilan 26 Jun 2011 16:19:42
mean shift Siamak Safarzadegan Gilan 26 Jun 2011 16:19:47
mean shift MadWiFi 15 Nov 2011 20:40:51
mean shift Karina Odinaev 18 Dec 2011 07:35:42

Contact us at files@mathworks.com