Ask Your Question
0

How to convet mat to a double array in java????

asked 2016-12-22 23:04:02 -0600

Neel Gohel gravatar image

updated 2016-12-23 00:54:45 -0600

berak gravatar image
Mat im= Imgcodecs.imread(d);
Mat inp=new Mat();
Mat newinp=new Mat();
inp.convertTo(newinp, CvType.CV_64F);
java.util.List<Mat> rgb=null;
Core.split(newinp, rgb);
Mat r1=rgb.get(0);
Mat g1=rgb.get(1);
Mat b1=rgb.get(2);
double[] r = null;
double[] b=null;
double[] g=null;

Now I want to convert Mat r1 to double[] r, Mat g1 to double[] g and Mat b1 to double[] b. What should I do???????

edit retag flag offensive close merge delete

Comments

may i ask, why you want to do this ? (also, why double[] ?)

berak gravatar imageberak ( 2016-12-23 00:57:08 -0600 )edit

I have a piece of code in Matlab, I am converting it to java.

Neel Gohel gravatar imageNeel Gohel ( 2016-12-23 01:06:12 -0600 )edit

opencv != matlab.

don't do that "line-by-line". tell us, what you're trying to achieve (on a higher level), then we can help you.

berak gravatar imageberak ( 2016-12-23 01:09:57 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
-1

answered 2016-12-23 01:04:38 -0600

pi-null-mezon gravatar image

You should check if r1 continuous (call r1.isContinuous()). Ad if it is, then get pointer to the beginning of the data: r = r1.ptr<double>(0), same for the g1 and b1.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-12-22 23:04:02 -0600

Seen: 1,780 times

Last updated: Dec 23 '16