With the following lines of code, I want to print the rgb histograms of a given image. The overall result is good, but comparing the three histograms with the ones obtained with gimp I noticed that some bins inside the histogram are missing, I mean that there is a white value where there should be a number different from 0 of pixel associated to that tone.
here is my code:
im = np.array(Image.open('myimage.jpg'))
plt.figure()
plt.hist(im[:,:,0].flatten(), 256, color='red', label='Histogram Red')
plt.figure()
plt.hist(im[:,:,1].flatten(), 256, color='green', label='Histogram Green')
plt.figure()
plt.hist(im[:,:,2].flatten(), 256, color='blue', label='Histogram Blue')
plt.show()