How to get pixelcount in image.

36 次查看(过去 30 天)
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.

采纳的回答

Image Analyst
Image Analyst 2016-12-9
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 个评论
Rukevwe Rim-Rukeh
Rukevwe Rim-Rukeh 2022-4-25
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,

请先登录,再进行评论。

更多回答(1 个)

Guillaume
Guillaume 2016-12-9
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 个评论
Deepika Rani
Deepika Rani 2016-12-9
What is meant by pixelcount?can you explain with one example.
Guillaume
Guillaume 2016-12-9
This is the exact question I asked, what do you mean by pixel count? Pixel count of what?

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by