MATLAB: How to mask a region other than region of interest in live video(webcam)

Image Acquisition Toolboxmasking the non-roi in live video

Hello all. currently, I am working on matlab computer vision program, where a human is detected in live video(webcam) with a region of interest. As I already done with this task but left with masking the region other than the region of interest(ROI) in the live video(webcam). More significantly, the masking process which is done should be in the same videoplayer, but not in other maskplayer. Could anyone please share some ideas or codes which would be helpful to solve this.

Best Answer

There are only two regions: the region(s) you're interested in, and the region(s) you're not interested in. If you want to mask out the region that is the region you're not interested in, then complement the mask of the ROI. So for example to mask out (set to zero) the region outside the region of interest, you'd do this:
grayImage(~roiMask) = 0;
Related Question