def img_hist(img): arr = np.array(img.getdata(), np.uint8) return np.histogramdd(arr[:,:-1], bins = 6, range = [[0, 256]] * 3, weights = arr[:,3])[0]