How do i write a histogram code without the built in functions ?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I want to creat a histogram code, knowing that it'll be counting the number of occurence of 3 values of a pixel.
the idea is i have 3 matrices (L1im, L2im, L3im) representing information extracted from an image, size of each of them is 256*226, and i want to compute how many times a combination of let's say (52,6,40) occures (each number correspends to a matrix/component but they're all of the same pixel)
for i = 1 : 256
for j = 1 : 256
for k = 1 : 256
if (L1im == i) & (L2im == j) & (L3im == k)
myhist(i,j,k)= myhist(i,j,k)+1;
end
end
end
end
can anyone help please ?
0 commentaires
Réponses (1)
Image Analyst
le 27 Mar 2021
That's obviously not correct. Try this 3 dimensional histogram
[L1im, L2im, L3im] = imsplit(rgbImage) % Optionasl, if you want to do this instead of operating on the RGB image directly in the loop
[rows, columns, numberOfColorChannels] = size(rgbImage)
myhist = zeros(256, 256, 256); % histogram for uint8 where gray levels go up to 255
for col = 1 : columns
for row = 1 : rows
r = L1im(row, col);
g = L2im(row, col);
b = L3im(row, col);
myhist = myhist(r, g, b) + 1;
end
end
Voir également
Catégories
En savoir plus sur Histograms dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!