<div dir="ltr"><div>I am working on implementing Image Processing Toolbox in
Scilab. For that I am implementing Opencv functions in Scilab through
C++ using functions defined in Scilab API "api_scilab.h".
<br><br>I am unable to return 3D matrices (which is returned by opencv function) through my C++
code to Scilab console. Currently, I
am converting 3DMatrix to 1D Matrix,
return it and convert 1D matrix back to 3D matrix
whenever required.<br><br>Is there any function in Scilab API by which I
can directly return or pass 3D matrix as argument. Is there any other
way I can return 3D matrix back to Scilab?<br><br></div>Imread function is shown below:<br><br> Mat img = imread(pstData[0],CV_LOAD_IMAGE_UNCHANGED); //3 dimensional matrix is returned from imread function //pstData[0] contains path of image<br> int *n = NULL; <br>
n = (int*)malloc(sizeof(int) *img.rows *img.cols *3);
//creating one dimensional matrix using malloc statement
<br> int i,j,k=0,r,b,g;<br> for(int i = 0;i < img.rows;i++){ <br> cv::Vec3b* pixel = img.ptr<cv::Vec3b>(i); //this is where i am assigning 3 dimensional RGB values into 1 dimensional array<br> for(int j = 0;j < img.cols;j++){<br> n[k]=pixel[j][2];k++; //that is my problem "is there any function defined in "api_scilab.h" with help of which we can directly <br> n[k]=pixel[j][1];k++; //pass 3 Dimensional matrix instead of converting into 1 dimensional matrix.<br> n[k]=pixel[j][0];k++;<br> }<br> }</div>