MATLAB: Sir I’m working a current project image process or image data acquistion the problem is i have to identify a color red and green when it pass to a live web cam or take a snapshot and i’m confused about the rgb color in matlab ex. if(rgb == red)

color segmentationimage processingImage Processing Toolboxtracking

Sir I'm working a current project image process or image data acquistion my problem is i have to identify a color red and green when it pass to a live web cam or take a snapshot and i'm confused about the rgb color in matlab ex. if(image == red) disp ('red'); if(image == green) disp ('green'); else ……

Best Answer

I think you should read Image Types for better understanding on rgb image in matlab.
Matlab splits red channel, green channel and blue channel in a m-by-n-by-3 data array where m and n are width and height. For example:
rgbImage = imread('yellowlily.jpg'); % Read image
redChannel = rgbImage(:,:,1); % Red channel
greenChannel = rgbImage(:,:,2); % Green channel
blueChannel = rgbImage(:,:,3); % Blue channel