Added kmeans codebook extraction method