How to get pixelcount in image.
34 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Deepika Rani
le 9 Déc 2016
Commenté : Rukevwe Rim-Rukeh
le 25 Avr 2022
I tried with [pixel-count x]=imhist(i), i is gray scale image but I got pixel-count=256xdouble like dis not value. Please help me with this, matlab code.
0 commentaires
Réponse acceptée
Image Analyst
le 9 Déc 2016
i is the imaginary number and would be an especially horrible name for an image. Change it.
Your subject line says "How to get pixelcount in image." and the answer to that, for a gray scale image, is
numberOfPixels = numel(grayImage);
Then you say "[pixel-count x]=imhist(i)" Well pixel-count is not even a valid variable name. You can't have a minus sign in the middle of a variable name. Perhaps it was a type, like using "dis" for "this". Maybe you meant
[pixelCounts, grayLevels] = imhist(grayImage);
In that case pixelsCounts is the number of pixels in each gray level bin of the histogram, NOT the total number of pixels in the image, which would be the sum of the pixel counts in each bin:
numberOfPixels = sum(pixelCounts)
4 commentaires
Rukevwe Rim-Rukeh
le 25 Avr 2022
Hello,
I want to find the number of pixels on the right handside or the left hand side of an image how do i do that
Thank you,
Plus de réponses (1)
Guillaume
le 9 Déc 2016
What pixel count?
imhist returns the number of pixels at each of 256 different gray levels. If you want more or less intensity levels, simply specify a different number of bins rather than using the default.
If you want to know the total number of pixels in the image, it's simply height*width, i.e.
numpixels = size(i, 1) * size(i, 2); %and you shouldn't call your image i.
2 commentaires
Guillaume
le 9 Déc 2016
This is the exact question I asked, what do you mean by pixel count? Pixel count of what?
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!