Ask Your Question
1

element wise division in android

asked 2014-11-04 03:21:26 -0600

Deepak Kumar gravatar image

updated 2015-10-06 09:10:10 -0600

hi, i have two mat variable. i want to do element wise division. same as ./ in matlab for element wise divison. when i am using Core.divide(); method i am not getting the same result. i also used Mat a = b.mul(1/c); this also does not gives desired result.

help me !! thanks

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2014-11-04 03:38:19 -0600

berak gravatar image

updated 2014-11-04 05:25:51 -0600

the docs are your friend):

// let's try: a/b=c ;
Mat a = new Mat(3,3,CvType.CV_32F,new Scalar(12));
Mat b = new Mat(3,3,CvType.CV_32F,new Scalar(2));
Mat c = new Mat();
Core.divide(a,b,c);
System.out.println( c.dump() );

[6, 6, 6;
 6, 6, 6;
 6, 6, 6]

note, that multiplying by 1/b like this:

Mat oob = new Mat();
Core.divide(1.0,b,oob);
Core.multiply(a,oob,c);

only works with float Mat's. (due to integer truncation)

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-11-04 03:21:26 -0600

Seen: 1,111 times

Last updated: Nov 04 '14