Convert all elements of a certain value in a Mat to another value [closed]

asked 2016-07-18 10:38:00 -0600

phillity gravatar image

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!

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by phillity
close date 2016-07-18 11:59:57.221406

Comments

1
  • multiply by 2
  • subtract 1 (Mat::ones())
berak gravatar imageberak ( 2016-07-18 11:11:38 -0600 )edit

Thank you!!!!!

phillity gravatar imagephillity ( 2016-07-18 11:59:43 -0600 )edit