how to count pixels having same value

댓글 수: 4

sum( myImage == someValue );
in the absence of any substantive information on what you are counting them in!
monika  SINGH
monika SINGH 2019년 4월 8일
i am having a thermal image of human face ,want to count the pixels having same value (x,y).
Depending on that you wanna count (one or more values) you can use this:
VALS=[1,2...N] % Array of values 1xN
thermIm= % Matrix of thermal image values
noVals=sum(sum(ismember(thermIm,VALS)))
noVals is the amount of pixels in thermal image containing the values stored in array VALS
If you have just one value you can just use a combination of "length" and "find"
VAL= % Random number 1x1
noVals=length(find(thermIm==VAL))
Image Analyst
Image Analyst 2019년 4월 8일
Please put Answers down in the Answer section.

댓글을 달려면 로그인하십시오.

 채택된 답변

Image Analyst
Image Analyst 2019년 4월 8일
편집: Image Analyst 2019년 4월 8일

0 개 추천

You can take a histogram:
histObject = histogram(yourImage);
or
[counts, grayLevels] = imhist(grayImage);

댓글 수: 1

monika  SINGH
monika SINGH 2019년 4월 11일
편집: monika SINGH 2019년 4월 11일
i am having a gray level image,and i want to set some range for pixel intensity like
if x[i,j]=183 to 215 ; (x[i,j]=pixel intensity )
then it would be of red color
else green
c programming of what i amasking is like this
for (i=0;i<n;i++)
{for(j=0;j<n;j++)
{
ifx[i,j]>=183||x[i,j]=215)
{
red color}
else
{green}
end}}
please give me matlab code for this

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

질문:

2019년 4월 8일

편집:

2019년 4월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by