Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV: Invert a mask?

Tags:

python

opencv

Is there a simple way to invert a mask using OpenCV? For example, if I've got a mask like this:

010 111 010 

I'd like to invert it and get this:

101 000 101 

Note: I'm using OpenCV's Python bindings, so while it would be possible to simply loop over each element in the mask, execution speed could become an issue.

like image 233
David Wolever Avatar asked Jul 16 '10 00:07

David Wolever


1 Answers

cv2.bitwise_not(mask) would help here

like image 117
Rikesh Subedi Avatar answered Oct 10 '22 07:10

Rikesh Subedi