implement k-means algorithm and use it to compress an image