Image color compression using Kmeans algorithm


I have two questions about this part, first when we compress the image size, each pixel color is classified to be one of the centroids , which is still 3 x 8 bits , how could we represent each pixel in 4 bits ?
the second is below in code i got an IndexError when i ran it outside the assignment , that said : index is out of pounds of axis 0 with size 16.

@Amr_hosni

Please think about these:

  1. how many different numbers do 3 x 8 bits represent?
  2. how many colors do 3 x 8 bits represent?
  3. how many bits do you need to represent 16 different numbers?
  4. how many bits do you need to represent 16 different colors?

please google about the meaning of the error message for your debugging.