I am trying to implement the threshold method, made with OpenCV, posted here. It is written in C++, so I am trying to rewrite it for myself to Java, for Android Studio. In the code here there is a line:res=1.0-res;
. "res" is Mat (OpenCV matrix, the same as: Mat mat = new Mat();
). How can I subtract 1.0, which is 'double' format from res, which is 'Mat' format in Java?
Asked
Active
Viewed 982 times
0

Community
- 1
- 1

Dainius Šaltenis
- 1,644
- 16
- 29
-
1Have you tried: `Core.subtract(new Scalar(1), res, res)`? – Miki Jan 14 '16 at 22:12
-
Thank you, it helped. I just changed it a bit: `Core.subtract(new MatOfDouble(1.0), res, res);`. From Scalar to MatOfDouble. – Dainius Šaltenis Jan 14 '16 at 22:19
-
For some reason it does not let me to accept my own answer: "You can accept your own answer in 2 days". Well, everyone will see it at least. – Dainius Šaltenis Jan 14 '16 at 22:23
1 Answers
0
Thank you, Miki, for helping to solve this. This is how it should be:
Core.subtract(new MatOfDouble(1.0), res, res);

Dainius Šaltenis
- 1,644
- 16
- 29