Ask Your Question
0

How to create Mat from rgb 2d arrays?????

asked 2016-12-28 01:24:17 -0600

Neel Gohel gravatar image

Mat om=new Mat();

double[] rx=new double[3];

for(int i=0;i< sizeA.height;i++)

{

for(int j=0;j< sizeA.width;j++)

{

        rx[0]=r3[i][j];

        rx[1]=g3[i][j];

        rx[2]=b3[i][j];

        om.put(i, j, rx);

}

}

I am using this code but I am not getting any output for the given code.

r3,g3 and b3 are the rgb arrays & sizeA is Size of the Mat.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2016-12-28 02:25:17 -0600

berak gravatar image

you have to allocate actual memory for your Mat, before you can fill it with put() calls:

Mat om=new Mat(sizeA, CvType.CV_64FC3);

then, note that it's BGR in opencv, not RGB, so you should use:

    rx[0]=b3[i][j];
    rx[1]=g3[i][j];
    rx[2]=r3[i][j];
edit flag offensive delete link more

Comments

Thanks again berak :D

Neel Gohel gravatar imageNeel Gohel ( 2016-12-28 04:18:36 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-12-28 01:24:17 -0600

Seen: 1,371 times

Last updated: Dec 28 '16