def recreate_image(codebook, labels, w, h):
    d = codebook.shape[1]
    image = np.zeros((w, h, d))
    label_idx = 0
    for i in range(w):
        for j in range(h):
            image[i][j] = codebook[labels[label_idx]]
            label_idx += 1
    return image

# Display all results, alongside original image
Recreate the (compressed) image from the code book & labels
dataset/ETHPy150Open scikit-learn/scikit-learn/examples/cluster/plot_color_quantization.py/recreate_image