Kmeans on patches