Histogram of colour levels

How could I produce a histogram of the grey levels in an image?

I would like to be able to get a .bmp image, put it into my program and then have that give me the grey levels of each pixel.

I could then put this data into Excel and produce a Histogram of it.

Can anyone tell/guide me to how I could get the data for each pixel?

Any help is much appreciated, thanks in advance!

glReadPixels will do nicely, but you don’t need openGL to do this job, it can be done by just loading the bmp and directly getting the histogram data from the image data.

alternatively use the GL_EXT_histogram extention
http://oss.sgi.com/projects/ogl-sample/registry/EXT/histogram.txt

Thanks so much for such a quick reply!

I’m having some compiler trouble atm so I will try it out later.

Thanks again!