Just got stuck at working with K-means clustering.
I have looked up this python/skimage commands:
image_array = image.reshape([-1,3]).astype(np.float32)
kmeans = KMeans(n_clusters=2, random_state=0).fit(image_array)
labels_array = kmeans.labels_
labels = labels_array.reshape([image.shape[0], image.shape[1]])
when I noticed that the RGB images hast to be converted to one long array. How can K-means clustering know about the 2 spatial dimensions (and the 3rd one - color) when I pass an array?
Or is just my assumption wrong that spatial information is needed? At least the goal is to minimize the within-cluster sum of squares. The distance in x, y and color direction is therefor important, isn't it?