How to interpret an image histogram and plot histogram3D for an image?

I'm really finding many ambiguities in how I really should interpret the histogram of an RGB image? I could understand what the height denotes, but did not understand how the pixels get plotted on a single dimensional x-axis. Also, is it possible to plot the image onto histogram3D? I tried after converting it to separate RGB images but I get an error that says it is not able to calculate the "bins" the diagram.

Thank you

• Have you read the wiki link:en.wikipedia.org/wiki/Image_histogram . For the Histogram3D part, I can't really understand what you are asking for. – mmjang Sep 20 '13 at 6:30
• Collect ImageData using 'Byte' type and you can see the pixel values clearly in n*n*n dimension. Loop to pick two from each set for Histogram3D. Each represents a color channel hence 3 per set. You can pick them separately and find simple Historgram. It shall match the below plotted onces. – Rorschach Sep 20 '13 at 9:59

The default is to not show any useful labelling, so perhaps it might be easier to do this:

i = ExampleData[{"TestImage", "Mandrill"}];
ImageHistogram[i, FrameTicks -> {True, True},
Appearance -> "Separated"] For the 3D aspect of your question, perhaps you want something like this:

{r, g, b} = ColorSeparate[ImageResize[i, 200]]
ListPlot3D[ImageData[r, DataReversed -> True], Mesh -> False,
ColorFunction -> "GrayTones"] — this is just the red channel.

This might be one more manual way to see Histogram.

image = Import["ExampleData/lena.tif"]
tr = ImageData[image, "Byte"]
tr // Dimensions (*{116,150,3}*)
a = Table[tr[[i, j]] /. {a_, b_, c_} -> a, {i, 116}, {j, 150}](*Similarly for b,c)

Sample Histogram computation is

Histogram[b, 100, ChartBaseStyle -> EdgeForm[None],  ChartStyle -> Green]

Now comparing Histogram for a,b & c with ImageHistogram respectively. we shall see similar results. We can see both of them resembling. So, to calculate Histogram3D you need two coordinates which you can extract as,

ab = Table[tr[[i, j]] /. {a_, b_, c_} -> {a,b}, {i, 116}, {j, 150}]
(*Similarly for bc,ca)

My system is old so, I could produce it only once as it took long time. I am not pasting graphics for Histogram3D but you can generate it by Histogram3D[ab].