MATLAB: I have an image with red,yellow and green pixels. How to find the percentage of yellow pixels

image processing

I have used red=img(:,:,1) and green=img(:,:,2) for the red and green pixels respectively.Is there any similar way to extract yellow pixels?

Best Answer

yellow = red == 255 & green == 255;
if you are using a uint8 image or replace 255 with whatever the data maximum is otherwise.
(Edited to reflect Guillaume's comment below!)