Quantize RGB colours into a palette.
This function uses k-means clustering to extract a palette from a data.frame representing the RGB values of pixels in an image. This is not the most state-of-the-art method of extracting a palette, but works as well as most photo editing software.
A data.frame representing the colours of the pixels in the image,
The number of colours to try to extract
A vector of colorspace library RGB objects.
1 2 3 4 5 6 7