Instead of implementing k-means clustering on the pixels of an image itself, it is far more efficient to cluster the image in superpixels first and operate on those in further steps.
The basic idea is to use an initial k-means clustering on the image pixels in the 5-dimensional xylab space. For this we need to be able to convert standard rgb to CIELAB.
Instead of implementing k-means clustering on the pixels of an image itself, it is far more efficient to cluster the image in superpixels first and operate on those in further steps.
I found a nice and easy algorithm for this: https://infoscience.epfl.ch/record/149300/files/SLIC_Superpixels_TR_2.pdf
The basic idea is to use an initial k-means clustering on the image pixels in the 5-dimensional xylab space. For this we need to be able to convert standard rgb to CIELAB.