clustering image, grayscale image
显示 更早的评论
Hello, I have for example image

I want convert to grayscale image, and then use Kmeans method.
Does anyone help ?
Thanks.
回答(2 个)
Image Analyst
2014-3-15
0 个投票
Use rgb2gray() from the Image Processing Toolbox. Then kmeans() from the Statistical Toolbox. Here's a demo: http://www.mathworks.com/products/demos/image/color_seg_k/ipexhistology.html
16 个评论
Tomas
2014-3-15
Image Analyst
2014-3-15
First tell me what you think your two clusters represent. What are the two axes - what are their units?
Image Analyst
2014-3-15
编辑:Image Analyst
2014-3-15
Then why are you converting to grayscale???? It doesn't make sense. Can you explain?
Why don't you try this File Exchange submission that looks like what you want to achieve: http://www.mathworks.com/matlabcentral/fileexchange/37197-dem-diffused-expectation-maximisation-for-image-segmentation

Tomas
2014-3-15
Image Analyst
2014-3-15
Again, that does not make sense. It's an image. Each pixel has a position specified by what row and columns it's in. What do you mean by "obtain the position of pixels"? For example, look at this small image of only 4 pixels:
123 234
73 37
Now if I were to ask you "give me the position of pixels in that image", what would you answer?
Tomas
2014-3-15
Image Analyst
2014-3-15
We can't help you unless you can accurately say what you want. The best I could do was to show you a color classification method that seemed to produce something similar to what you showed that you want.
Tomas
2014-3-15
Image Analyst
2014-3-16
But do we really need to carry out this same conversation in two different threads? Respond to each of them and let me know which one you will continue with and which you will abandon, because I don't want to monitor two threads on the same thing and answer the same thing twice.
Tomas
2014-3-16
Image Analyst
2014-3-16
I don't know what your question is, if any. And I'm having trouble matching your mindset. A gray level is a 2D image. Even if you plot it as a 2.5D surface where the height above the plane is the gray level, it's still a 2D image because there are two independent variables (row & column) and one dependent variable (the gray level). In 1D, if I had a vector [3,5,8,16,22] everyone says that's a 1D vector, not a 2D signal just because you could plot that values along the y axis and the index along the x axis. Or consider a sine wave - it's a 1D signal, not a 2D signal just because you plot it in the x,y plane.
I don't how you used kmeans. You simply have a colormap applied. You just say that if the gray level is less than about 64, make it red, and if it's between 64 and 145 it's green, and if it's greater than 145 it's blue. You don't need kmeans for that, you can use ind2rgb(). And I don't know what you did for the color image, for example did you use rgb2gray(), rgb2hsv() and use the v channel, or did you just take one of the color channels, or something else. Anyway, I'm not sure if you have a question or if we're done. I don't have the stats toolbox so I can't actually try any code with kmeans() in it.
Tomas
2014-3-16
Image Analyst
2014-3-16
Sorry I don't understand the language. I don't know what to click, and it started spewing out a bunch of stuff that I didn't know what it was into the command window. It went on for several minutes and I couldn't stop it, not even with control-C. I had to go into task manager to finally kill off MATLAB.
I suggest you try normal debugging operations to figure out what's going on.
Boni_Pl
2016-11-12
0 个投票
Please anyone upload a matlab code for kmeans clustering of an ultrasound image.
类别
在 帮助中心 和 File Exchange 中查找有关 k-Means and k-Medoids Clustering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





