MATLAB: Applying thresholds simultaneously in SimpleColo​rDetection​ByHue()

color segmentationimage analysisimage processingImage Processing Toolbox

I'm trying to use this program to detect not one but three different colors (red green blue) at the same time, applying three different thresholds. Is there a way? Try to explain each little step because I haven't used Matlab for a while and I'm a bit rusty. Thank you all!

Best Answer

Yes, basically just do each color one at a time and get a mask for each one, then OR them together.
% Set hsv thresholds for color1
maskColor1 = ........ % Create mask based on those thresholds.
% Set hsv thresholds for color2
maskColor2 = ........
% Set hsv thresholds for color3
maskColor3 = ........
% Get the mask for all 3
allThreeColorsMask = maskColor1 | maskColor2 | maskColor3;