Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

to apply cv2.kmeans, you need a single, 2d matrix, where each row is a flattened 1d image, and convert to float:

images = np.asarray(images, np.float32) N = len(images) images = images.reshape(N,-1)

to apply cv2.kmeans, you need a single, 2d matrix, where each row is a flattened 1d image, and convert to float:

images = np.asarray(images, np.float32)
N = len(images)
images = images.reshape(N,-1)

images.reshape(N,-1)

to apply cv2.kmeans, you need a single, 2d matrix, where each row is a flattened 1d image, and convert to float:

images = np.asarray(images, np.float32)
N = len(images)
images = images.reshape(N,-1)

also: https://github.com/opencv/opencv/blob/master/samples/python/kmeans.py