Implement kmeans denoiser.