how to set x-axes in a histogram of gray scale image and how to see if the image is saturated (12 bit)
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, I am trying to plot a histogram of a unit16 picture (actually its a 12 bit image) and plot the gray scale. I am interested to see if the image gets saturated or not (again 12 bit image). Which btw i find weird its only the first 12 that is populated with a very huge number. Why is that? i only have a image of an laser lobe in the picture.
So my question is, because the histgram looks weird in the appdesigner plot, i think it doesn't seem to adjust to the pixel count in the picture in the x-scale. Y-scale has a huge number. What does this represent? How can i see if the picture is staurated? 2^12 = 4096 should be the max intensity of the image. but I get maxcount = 2123959
Any ideas how set the x-axes as well?
Bits of the code (from the appdesigner)
% Create histograms based on number of color channels
switch size(im,3)
case 1
% Display the grayscale image
imagesc(app.Image,im);
% Plot all histograms with the same data for grayscale
hist = histogram(app.HistAxes,im, 'FaceColor',[1 0 0],'EdgeColor', 'none');
%[counts,binLocations] = imhist(im);
otherwise
% Error when image is not grayscale or truecolor
uialert(app.UIFigure, 'Image must be grayscale.', 'Image Error');
return;
end
% Get largest bin count
maxim = max(hist.BinCounts);
maxcount = max([maxim])
% Set y axes limits based on largest bin count
app.HistAxes.YLim = [0 maxcount];
app.HistAxes.YTick = round([0 maxcount/2 maxcount], 2, 'significant');
0 Commenti
Risposte (3)
Image Analyst
il 17 Feb 2021
If the maxcount is 2123959, then that just means that the highest bin has a y value of 2123959. That bin could be anywhere along the x (gray scale) axis. If you look at the bin for 4095, and there are some values in there, and you have 4096 bins, then yes, some pixels are saturated. It is also possible to saturate at a gray level value that is not the maximum for the number of bits you're using for a variety of reasons. So you should look to see if the last bin or two is much higher than the bins just a little darker than those.
1 Commento
Steven Lord
il 17 Feb 2021
You haven't specified the bin edges, the bin method, or the bin width in your histogram call. Because of this I'd be concerned that your bins may be wide enough that they count multiple values in your data.
x = randi(1e4, 1, 1e6);
subplot(2, 1, 1)
h1 = histogram(x);
subplot(2, 1, 2)
h2 = histogram(x, 'BinMethod', 'integers'); % Each integer gets its own bin
fprintf("The bins in histogram h1 are %d units wide, " + ...
"while the bins in histogram h2 are %d unit wide.\n", h1.BinWidth, h2.BinWidth)
fprintf("The first bin in h1 is the range [%d, %d) " + ...
"while the first bin in h2 is the range [%g, %g).\n", ...
h1.BinEdges(1:2), h2.BinEdges(1:2))
0 Commenti
Vedere anche
Categorie
Scopri di più su Histograms in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!