MATLAB: How to detect yellow and white colors simultaneously in a live video?

color detectioncolor segmentationImage Processing Toolboxwhiteyellow

I came across the codes to detect yellow and white colors from a live video. But, these are the codes that allow to detect only one color, either of them. If at all I want to detect multiple colors,yellow and white in this case, hoe can I do it?

Best Answer

I have all kinds of color segmentation routines in my file Exchange http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 Just detect white and yellow and AND them together. Or do it in one shot:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Threshold each channel with the right thresholds
whiteAndYellow = redChannel > redThreshold & ...
greenChannel > greenThreshold & ...
(blueChannel > blueThreshold1 | blueChannel < blueThreshold2);
Play around with the threshold values until you find some that work.
Related Question