필터 지우기
필터 지우기

How to calculate no. of pixels having value greater than a particular RGB value?

조회 수: 11 (최근 30일)
Dhrubajyoti Das
Dhrubajyoti Das 2013년 11월 6일
댓글: Guillaume 2018년 11월 8일
I want to calculate the no. of pixels having value greater than a particular RGB value for eg. lets say 180. (pic(mm,nn,1) > 180 && pic(mm,nn,2) > 180 && pic(mm,nn,3) > 180).

답변 (3개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 6일
편집: Azzi Abdelmalek 2013년 11월 6일
idx=pic>180
out=sum(idx(:))

Image Analyst
Image Analyst 2013년 11월 6일
% Extract the individual red, green, and blue color channels and threshold them.
binaryR = rgbImage(:, :, 1) > 180;
binaryG = rgbImage(:, :, 2) > 180;
binaryB = rgbImage(:, :, 3) > 180;
% AND the binary images together to find out where ALL THREE are > 180.
binaryImage = binaryR & binaryG & binaryB;
% Count the number of pixels where it's true that all 3 are > 180;
pixelCount = sum(binaryImage(:));
  댓글 수: 4
Anbarasan Rajan
Anbarasan Rajan 2018년 11월 8일
pixelCount=sum(binaryImage(:)); i think this will only give us the total pixel intensity. for example, if 10 pixels are having the intensity of 50, this comment will give us 500 which is the total intensity value of the pixels present in thet image.
if i'm wrong please let me know.
Guillaume
Guillaume 2018년 11월 8일
"if i'm wrong please let me know."
You're wrong. binaryImage is 1 when all 3 channels of the pixel is above the threshold, and 0 otherwise. Hence the sum is the number of pixels, Image Analyst could have used nnz instead:
pixelCount = nnz(binaryImage);

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


suganya sri
suganya sri 2017년 11월 13일
how to find pixel value in somelocation, pls anybody help me

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by