Ask Your Question

I want to multiply a matrix with a number !

asked 2016-02-24 01:20:50 -0500

Pulkit gravatar image

I am using opencv in android studio.

i want:

Mat A;

Mat B;

int num= 255;

B = A*255;

But it is not working.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-02-24 02:02:33 -0500

berak gravatar image

there are no builtin 'operators' for this in java, you'll have to use Core.multiply , like:

Mat A = ...;
Mat B = new Mat();
Scalar s = new Scalar(13);
Core.multiply(A, s, B);

note, since B will get saturated on overflow, you probably need to convert A to a larger type, like CV_32F

edit flag offensive delete link more


It Worked for me . Thanks for the answer @berak Cheers !!

Pulkit gravatar imagePulkit ( 2016-02-24 23:26:44 -0500 )edit

Question Tools

1 follower


Asked: 2016-02-24 01:20:50 -0500

Seen: 2,767 times

Last updated: Feb 24 '16