OpenCV bitwise_and + mask

后端 未结 2 627
孤独总比滥情好
孤独总比滥情好 2020-12-18 05:45

I have this mask :

\"mask\"

Let\'s say I would like to make a bitwise_and with another image to fill in

相关标签:
2条回答
  • 2020-12-18 06:11

    The solution is pretty simple. Since I didn't know much about the openCV library I wasn't using the right function for the task. I'm still not certain for sure why the application crashed when passing a mask to the bitwise_and method though.

    Essentially all you have to do is the following :

    image.copyTo(dst, mask);
    

    This will copy the image to dst and even handle the details of the mat to give it the same properties as 'image'. Just have to make sure to have mask be an 8-bit single channel image. This way when you call the method only the pixels that pass the mask will be copied to dst.

    Here's the doc link for more information:copyTo

    0 讨论(0)
  • 2020-12-18 06:20

    just create a new canvas larger than the fox_image

    then use the “AND” method

    or, you can translate the black part of the first image into white: 0 ---255

    then, the problem would be solved.

    0 讨论(0)
提交回复
热议问题