Plotting a color histogram in python

I have a jpeg image and want to plot a histogram of how often each color appears in the image. I can generate a frequency table using pymorph.histogram (), but I don't know the actual color that each of the 256 colors matches. How can I create this palette? Also, is there a way to generate a histogram plot of all these numbers with the colors specified (not a number in the range 0-255, but the actual color is displayed)?

My frequency list is generated with this code:

import pymorph
import Image

im=Image.open('image.jpg')
im=np.asarray(im)
hist_im=pymorph.histogram(im)

      

+3


source to share


1 answer


Well, I'm not sure with pymorph, but if it doesn't produce what you expected, there is no harm in trying alternatives and that is the miracle of python programming.



This is probably what you are looking for: http://tophattaylor.blogspot.de/2009/05/python-rgb-histogram.html

0


source







All Articles