How to find the number of pixels with intensity
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Davidson Bock
am 23 Jan. 2018
Kommentiert: Matt J
am 23 Jan. 2018
I'm trying to find the histogram of an image. I'm supposed to use loops to calculate it. So far, my code is
histogram = = zeros(256,1,'int16');
for j = 0 : 255
histogram(j + 1) = number of pixels with intensity j
end
The problem I'm having is that I'm not sure how to find the number of pixels with intensity j. I know that I should use either the find() or sum() function, but I don't know how to format that part of the code
0 Kommentare
Akzeptierte Antwort
Matt J
am 23 Jan. 2018
Bearbeitet: Matt J
am 23 Jan. 2018
One way,
histogram(j + 1) = nnz(yourImage==j);
Or,
histogram(j + 1) = sum(yourImage(:)==j);
2 Kommentare
Matt J
am 23 Jan. 2018
You're welcome, but please Accept-click the answer to confirm that it resolved your issue.
As for saving, you should write the code in the Editor Window and use the file save button on the toolbar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Histograms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!