Algorithms for codebook generation, clustering, appearance based models, e.t.c.