I need to write a bit of code that will get a list of the RGB colours in an image and then translate them into a NumPy array of lab colours. I have managed to do this, but I would like to learn how I can do it more efficiently. from skimage.color import rgb2labfrom skimage.io import imreadimport numpy as npfrom PIL import Image  # @UnresolvedImportdef get_histogram (img):    #histogram = plt.hist(img.flatten(), bins=100, facecolor='green', alpha=0.75)    w, h = img.size      colours = img.getcolors(w*h)  #Returns a list [(pixel_count, (R, G, B))]    num, colours_rgb = zip(*colours)    r,g,b = zip(*colours_rgb)    num_of_colours = len(r)    w2,h2 = 1,num_of_colours    data = np.zeros( (w2,h2,3), dtype=np.uint8)    print(data.shape)    data[0,:,0] = r     data[0,:,1] = g     data[0,:,2] = b    print(data)    colours_lab = rgb2lab(data)
Getting list of colours from image in lab format
python;beginner;image