New to Matlab, Trying to superimpose histograms!

1 view (last 30 days)
Hi! I have been using the 'impixel' command to develop 10 5x5 samples of a greyscale image. Using these samples I have tried to create histograms using the 'imhist' function. But I am stuck on how to superimpose the 10 histograms I have created into one histogram.
I've tried to define the histograms as variables and then using the plot function, however this isn't working. Nor is using imhist(Matrix1,Matrix2...Matrix10).
Basically my question is, How can I superimpose histograms?

Answers (2)

dpb
dpb on 19 Jul 2014
Don't have Image Processing Toolbox here so can't use imhist directly, but I'd presume like regular hist and/or bar you can use it the first time to generate the plot and then
hold on
Oh, looking at the online doc, imhist is another of those aberrations that doesn't support an axes handle as an input so it looks like it will create a new figure irregardless.
As the later example there shows, generate the counts w/ imhist and then use stem to plot them. Again, the first will be a new figure, then
hold on
followed by a loop for each subsequent figure. Or, build and array of counts by column and a single call to stem will do them all at once.
doc stem
for the details on it.

Image Analyst
Image Analyst on 20 Jul 2014
If you want to superimpose lots of histograms, I think the best option is to use plot(counts, 'Color', [r,g,b]) rather than bar().

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!