Ask Your Question

How to do element wise division in java using Mat.mul?

asked 2016-12-22 03:13:33 -0500

Neel Gohel gravatar image

Suppose I have to Mat,i want to do element wise division(m1./m2), Then how to do it using Mat.mul method?

edit retag flag offensive close merge delete


what are m1, m2, exactly ? why do you want to use mult() for division ?

you can replace division by multiplication only, if m2 is a scalar.

berak gravatar imageberak ( 2016-12-22 03:19:27 -0500 )edit

Mat m1=new Mat(); Mat m2=new Mat();

Now I want to divide m1 & m2 elementwise, So what should be scalar value?

Neel Gohel gravatar imageNeel Gohel ( 2016-12-22 03:29:44 -0500 )edit

ok, let me clarify, if m is a matrix, and you have a number, like 5, you can replace the m/5 division by multiplying by 0.2. (but this is only valid for single numbers (Scalars))

berak gravatar imageberak ( 2016-12-22 03:35:30 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-12-22 03:24:08 -0500

berak gravatar image

updated 2016-12-22 03:27:39 -0500

i guess, the problem is, that you found a Mat.mul() member function, but there is no Mat.div() or similar.

use Core.divide(src1, src2, dst) in that case.

edit flag offensive delete link more


But will Core.divide do element wise division?

Neel Gohel gravatar imageNeel Gohel ( 2016-12-22 03:30:59 -0500 )edit

yes, that's element-wise. (there is a matrix multiplication in maths, but no such counterpart for division).

berak gravatar imageberak ( 2016-12-22 03:33:25 -0500 )edit

oh I forgot that thing, Thank you for help berak....:D

Neel Gohel gravatar imageNeel Gohel ( 2016-12-22 03:34:36 -0500 )edit

Question Tools

1 follower


Asked: 2016-12-22 03:13:33 -0500

Seen: 885 times

Last updated: Dec 22 '16