How to “zero” everything within a masked part of an image in OpenCV

前端 未结 3 1380
春和景丽
春和景丽 2021-02-19 13:27

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

3条回答
  •  情话喂你
    2021-02-19 13:39

    Multiply or bit-and the mask with the image. There are some OpenCV functions for that, but I do not know their names for the C interface.

    in C++:

    Mat image, mask;
    
    image = image * mask;
    // or 
    image = image & mask;
    

提交回复
热议问题