MATLAB: Color image segmentation using K-Means

kmeans

The Example for Color image segmentation which I was found here Here. In this example they have segmented the blue color. Is there any example to segment only the red color or green color?

Best Answer

  • I think you don't understand how k-means works. You specify k. In the example they specified 3 because they thought there should be, or wanted to be, 3 classes. Those three classes were magenta, blue, and white for that particular image. For your image they might be something different, say yellow, green, and cyan - it all depends on the content of the image. If your image has only two main colors, red and green, then maybe you should specify a k of 2 and it will find those two colors. Feel free to upload your image to the website of your choice if you want us to look at it.