Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

share|improve this question
2  
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. –  mm.Jang 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

2 Answers 2

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"]

mandrill histogram

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"] 

red channel of mandrill

— this is just the red channel.

share|improve this answer

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. enter image description here

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].

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.