mattnedrich / meanshift_py Goto Github PK
View Code? Open in Web Editor NEWSimple implementation of mean shift clustering in python
License: MIT License
Simple implementation of mean shift clustering in python
License: MIT License
Hi mat,
Can you add some instructions about how to pass a 3D dimension image like RGB into the function? Besides, it looks when the size of image increase, you have to wait lots of time, so is there any recommended iteration number for breaking from the loop?
Best,
Haodong
hello, can you share the code for getting the image segment result ?
I run the code with around 100 *10^3 points but I did not finish after 24 hours. I do not the reason.
Can any one help me to speed up the code with large size data.
Best,
I transformed every RGB pixel of the image to a point in a 3d space, then mean shift the points to get the shifted points, but it took quite a long time to get the result because an image usually has hundreds times hundreds pixels.
I would like to generate images (like "ms_2d_bw_.8.gif"), but I don't see anything image related in the source code.
Where/how did you get those images?
Hi Matt!
First of all, thank you very much for this implementation, I found it very useful along with the blog post! :)
I did an implementation of a multivariate gaussian kernel, instead of a univariate gaussian kernel (as the one implemented). I needed for image processing, to find fixation points from raw gaze data.
I was wondering if you would be interested in a pull request with the implementation of the multivariate gaussian kernel.
Cheers,
Marc
PD: I wasn't sure where to put this messege, sorry if it shouldn't go in Issues ^^'
Hi mat, I appreciate your code! However in the following code, when I inspect the variable index
, I found that the it is initialized once and then incremented in the loop, however it is never used to assign to anything. And this variable isn't passed to any other function, too. So I wonder is this a redundant variable? If so I think deleting it would make the logic clearer.
def group_points(self, points):
group_assignment = []
groups = []
group_index = 0
index = 0 # initialization
for point in points:
nearest_group_index = self._determine_nearest_group(point, groups)
if nearest_group_index == None:
# create new group
groups.append([point])
group_assignment.append(group_index)
group_index += 1
else:
group_assignment.append(nearest_group_index)
groups[nearest_group_index].append(point)
index += 1 #increment
return np.array(group_assignment)
import numpy as np
import mean_shift as ms
mean_shifter = ms.MeanShift()
mean_shifter.cluster(np.array([[1,1], [1,2], [5,5]]), kernel_bandwidth = 2)
# no response, Ctrl + C
mean_shifter.cluster(np.array([[1.0,1.0], [1.0,2.0], [5.0,5.0]]), kernel_bandwidth = 2)
# works
Is it a bug? I would say it should accept integers also.
The Gaussian Kernal algorithm in your code has a mistake:
def gaussian_kernel(distance, bandwidth):
euclidean_distance = np.sqrt(((distance)**2).sum(axis=1))
val = (1/(bandwidth*math.sqrt(2*math.pi))) * np.exp(-0.5*((euclidean_distance / bandwidth))**2)
return
Where val = (1/(bandwidth*math.sqrt(2*math.pi))) * np.exp(-0.5*((euclidean_distance / bandwidth))**2)
should be
val = (1/(bandwidth*math.sqrt(2*math.pi))) * np.exp(-0.5*((euclidean_distance / bandwidth)**2))
.
-0.5*((euclidean_distance / bandwidth))**2
->-0.5*((euclidean_distance / bandwidth)**2)
Hi,
I don't use Python on regular basis, so maybe I don't understand something here, but how exactly am I supposed to include your code in my project? Usually I load stuff with PIP, but it seems that you haven't publish PIP package for this repo.
So I tried using git submodule and it seems ok, but I've got a problem with absolute imports - I use Python 3 so statements like import point_grouper as pg
won't work unless I include your code in my project root directory - which would be so hacky. ๐
I think this could by fixed by replacing import lines with something like from . import point_grouper as pg
. What do you think about this?
I feel that PIP package would be more elegant solution.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.