If I have an image (IplImage 8-bit) and a binary mask (which is also an 8-bit IplImage of the same size, where every pixel has a value of either 0 or 255), how can I make every
Simplest way, with 'Mat img' (image to be masked, input) and 'Mat masked' (masked image, output):
img.copyTo(masked, mask)
where 'Mat mask' is a matrix not necessarily binary (copyTo considers elements with zero value). Masked can be of any size and type; it is reallocated if needed.