1 | initial version |
You don't need to create zero-filled Mats to store stuff, this is not MatLab, you should make use of openCV's advantages! First, to assign values to a matrix you should use the setTo method.
Mat A, B;
A = stuff;
B = other stuff;
A.setTo(255, B);
This code sets in A all non-zero elements in B to 255.
To get difference between Mat use the absdiff function.
Mat A, B, diff;
A = stuff;
B = other stuff;
absdiff(A, B, diff);
Just make sure A and B are of the same type.