histogram plot is emplty
Show older comments
I have errors in displaying the histogram for a matrix (3648x5472). The histogram displayed is blank. The matrix value is in uint8.
Accepted Answer
More Answers (1)
Star Strider
on 1 Jul 2017
You probably need to use the imhist function, since your uint8 array may be an image.
This works for me:
M = randi(intmax('uint8'), 3648, 5472, 'uint8'); % Create Matrix
H = imhist(M);
figure(1)
bar(H)
2 Comments
Selina Loh
on 1 Jul 2017
Star Strider
on 1 Jul 2017
Knowing it was a binary image would have helped. If you want to know the number of true or ‘1’ values, you do not need a histogram. Simply count the ‘1’ values, and if you want the fraction that are ‘1’, divide by the total number of elements in the binary image:
BinaryImage = randi([0 1], 3648, 5472, 'uint8'); % Create Binary Image
NrEq_1 = nnz(BinaryImage); % Number Of ‘1’ Values
Frac_1 = NrEq_1/numel(BinaryImage); % Fraction Of Total That Are ‘1’ Values
Categories
Find more on Histograms in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!