1

I want to segment RGB images(satellite imagery) for land cover using k means clustering in such a fashion that the different regions of the image are marked by different colors and if possible boundaries are created separating different regions.

Is it possible to achieve this by K-means clustering? I have been searching all over internet and many tutorials do it by k means clustering but only after converting the image to grey scale. I want to do it with an RGB image only. Is there any source that could help me begin with with? Please suggest something.

RachJain
  • 283
  • 1
  • 5
  • 14
  • This question is probably too broad for SO. And in its current form it's rather vague. Are the regions that you want to identify regions of approximately similar colour? FWIW, k-means clustering _can_ be used to perform colour quantization on RGB images. However, standard k-means may not be good for your task, since you need to specify `k` (the number of regions) in advance. Perhaps a different approach like [growing self-organizing map](https://en.wikipedia.org/wiki/Growing_self-organizing_map) would be better. – PM 2Ring Jul 01 '15 at 07:52
  • Thank you for your help. As to clarify my question, I want to perform the image segmentation of the satellite imagery for land cover as an application to GIS and so the regions have different colors, intensities as well as textures. As for K means clustering, I have gone through the literature of the land cover classification which is my project and found that the best results are obtained from K means clustering algorithm being used for image segmentation. Now please suggest suggest something in this context. – RachJain Jul 01 '15 at 08:38

2 Answers2

1

I imagine it is not relevant for RachJain but if someone needs in the future: A simple use of sklearn KMean algorithm will give the wanted outcome:

from sklearn.cluster import KMeans
pic = np.float64(misc.imread(filepath)/255)
kmeans = KMeans(n_clusters=13, random_state=0).fit(pic)
pic2show = kmeans.cluster_centers_[kmeans.labels_]
plt.imshow(pic2show)
Dvir Itzko
  • 404
  • 4
  • 17
0

What do you mean that they convert the image to greyscale? The formula calculates the Euclidean distance of a point from a centroid. Therefore R, G, B values are used. Read this student report for a comparison of using different colour spaces - RGB or HSV: http://www.cs.bgu.ac.il/~ben-shahar/Teaching/Computational-Vision/StudentProjects/ICBV121/ICBV-2012-1-OfirNijinsky-AvivPeled/report.pdf

riddler
  • 467
  • 3
  • 13
  • When I say they convert it to greyscale first, here is a link to that [link](http://scikit-learn.org/stable/auto_examples/cluster/plot_lena_segmentation.html) – RachJain Jul 01 '15 at 08:43
  • It's not converted to greyscale, the image itself obtained by the function scipy.misc.lena() is in greyscale. Look up graph cuts - they might be more suitable for satellite imagery. – riddler Jul 01 '15 at 08:49