Borrar filtros
Borrar filtros

How do I calculate the histogram for an image using only for loops?

2 visualizaciones (últimos 30 días)
So the question is: 2.a) For the image loaded (Ig), using ONLY for loops, calculate the histogram for the image, plot the results as the number of occurrences per pixel intensity level, and print which intensity level has the most occurrences. NO MATLAB functions may be used besides length and/or size. (Don’t worry if it takes time to run. Give it a few minutes.) 2.b) Can you find a MATLAB function which will quickly accomplish this for you? If so, what is it called and how would you use it?
So far I have tried to calculate the histogram and I think it was doing it right. But I'm unsure of how to sort it and graph it. Any help would be greatly appreciated.
figure; imagesc(Ig); colormap(gray);
[row, col] =size(Ig);
h = zeros(256, 1);
for i=1:row
for j=1:col
Z=Ig(i,j);
% Ig is image
h(Z+1)=h(Z+1)+1;
end
end

Respuestas (0)

Categorías

Más información sobre Histograms en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by