필터 지우기
필터 지우기

How to count number of red, blue and green pixels in image.

조회 수: 4 (최근 30일)
k khaja
k khaja 2022년 10월 8일
댓글: Walter Roberson 2022년 10월 8일
Hi,
I woud like to know, how can I count number of red, blue and green pixels in image.
Thanks in advance
  댓글 수: 3
John D'Errico
John D'Errico 2022년 10월 8일
편집: John D'Errico 2022년 10월 8일
Pixels are almost never fully red, green, or blue. And what you might call red, green, or blue might not be what I would call those colors. So a slightly orangish red, is it still a red pixel? How far does it need to deviate into orange, before it stops being red? Maybe you use the supreme court definition of such a thing: that is, you know what red is when you see it.
You probably need to think about these questions before proceeding.
Walter Roberson
Walter Roberson 2022년 10월 8일
If RGB components are integers 0 to 255, then is [1 0 0] red? That is, the smallest change towards red away from black: does that count as red, or does it count as black? It has red component but not green or blue... under some definitions that would have to count as red.
rng(12345);
Z = zeros(48, 64, 3, 'uint8');
r = randi(size(Z,1),1,1);
c = randi(size(Z,2),1,1);
Z(r, c, 1) = 1;
image(Z)
title('which is the Red pixel?')
fprintf('Red pixel is at x = %d y = %d\n', c, r);
Red pixel is at x = 21 y = 45
Personally I cannot detect the red pixel until you get up to around 40 instead of 1

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by