Correct patch sampling.
Add KMeans.
Refactor k-means.
Add python bindings for k-means.
Compile python bindings with NDEBUG.
Add some checks.