I encountered the following while trying to convert some C++ code that uses OpenCV to Java. I'd like to know what the
Mat edge_enhanced_mser = ~gradient_grown & mser_mask;
It is the equivalent of the bitwise NOT operator overloaded for the
Mat class. In this case, it will invert all bits in the matrix. It is listed in the section Matrix Expressions in the documentation:
Bitwise logical operations: A logicop B, A logicop s, s logicop A, ~A, where logicop is one of : &, |, ^.
In Java, you can use the
public static void bitwise_not(Mat src, Mat dst)
Inverts every bit of an array.
Note you need a new
Mat to store the result: