Find out where all color channels are darker than some threshold, then and the masks and take the largest blob
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
threshold = 20;
mask = (redChannel < threshold) & (greenChannel < threshold) & (blueChannel < threshold);
backgroundMask = bwareafilt(mask, 1);
footMask = ~backgroundMask;
Best Answer