Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Convert all elements of a certain value in a Mat to another value

I am converting some matlab code to java using OpenCV 3.1

I am converting a matrix made up of 0 and 1 elements to a matrix of -1 and 1 elements by converting all elements of value 0 to value -1

Here is the line of code that does this in matlab:

  • keySequence(keySequence(:,:)==0)=-1;

Is there any OpenCV functions could accomplish this? I am not really sure how to iterate over every element. Any help would be very appreciated, thank you!