# from MAT to BIDIMENSIONAL ARRAY

Does a function doing this work exists? I need to change a Mat objecto into a bidimensional array to work with every element.

Thanks to help

edit retag close merge delete

if I pass to a function a Mat object ass a Mat **name , after can i transfer every element to a bidimensional array?

Sort by » oldest newest most voted

if it's actually a bidimensional Array, you could even try to make a Mat from that:

Mat m1 = Mat::ones(3,3,CV32F); // placeholder for your mat there

float bd_arr = {{1,2,3},{4,5,6},{7,8,9}};
Mat m2(3,3,CV_32F,bd_arr);
Mat m3 = m1 * m2;


note, that this won't work with an array of pointers, a dynamically allocated 2d array like this:

float **bad = new float*;
bad = new float;
bad = new float;
bad = new float;


(totally different memory layout)

more

A mat object is 2 D or 3 D array , if we consider that your mat object is 2 D so it is obligatory an array with dimension 2 , you can access to each element in your object mat "im" using for example :

for (int i = 0; i < im.rows; i++)
{
for (int j = 0; j < im.cols; j++)
{
uchar p1 = im.at<uchar>(i, j);// you can access to each element (row/col)

}
}

more

                     for (int i = 0; i &lt; rows; i++){
for (int j = 0; j &lt; cols; j++){
imfft=imfft*filter[i][j]
}}


I have to multiply an array with a mat

Official site

GitHub

Wiki

Documentation

## Stats

Asked: 2013-05-28 10:30:26 -0500

Seen: 185 times

Last updated: May 28 '13