Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

They are doing something strange. Normally you do use one of the inputs as binary. For an RGB image, your binary image would be 3 channels, with 255 being ON, and 0 being OFF. The on remain the same, and the off become black. There might be a few occasions where two non-binary images are used. After all, the images are stored in binary and they can be manipulated that way. Perhaps make all the values even by doing a binary_and on a value with only the last bit unset.

They are using this in a way that may not be entirely safe. Where the mask is empty, the result in the output is unchanged from what is there before. So if masked is filled with garbage instead of zeros...

In short, they are doing what in c++ would be this. However, I don't know if Python has the setTo method, it's not in the tutorials. Also, they might be saving some time, but I don't think so.

bitwise_not(mask, mask);
image.setTo(0, mask);