필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Hannah Chamberlain
Hannah Chamberlain 2016년 4월 28일
편집: Hannah Chamberlain 2016년 4월 28일
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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by