# EE4 Selected Topics From Computer Vision Coursework # Vasil Zlatanov, Nunzio Pucci CLUSTER_CNT = 1337 KMEAN_PART = 33 import numpy as np import matplotlib.pyplot as plt from sklearn.cluster import KMeans train = [] test = [] train_part = np.hstack(train[0:KMEAN_PART]) kmeans = KMeans(n_clusters=CLUSTER_CNT, random_state=0).fit(train_part) codewords = [] i = 0 for image in train: codewords.append(np.bincount(kmeans.predict(image) print codewords[i].shape