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

1 view (last 30 days)
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?

Accepted Answer

Image Analyst
Image Analyst on 6 Feb 2015
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.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!