[Scilab-Dev] dev at lists.scilab.org

priyanka hiranandani priyankahiranandani at gmail.com
Mon Jun 1 10:52:07 CEST 2015


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".

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.

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?

Imread function is shown below:

 Mat img = imread(pstData[0],CV_LOAD_IMAGE_UNCHANGED);        //3
dimensional matrix is returned from imread function    //pstData[0]
contains path of image
        int *n = NULL;
        n = (int*)malloc(sizeof(int) *img.rows *img.cols *3);
//creating one dimensional matrix using malloc statement
        int i,j,k=0,r,b,g;
        for(int i = 0;i <
img.rows;i++){
        cv::Vec3b* pixel = img.ptr<cv::Vec3b>(i);
//this is where i am assigning 3 dimensional RGB values into 1 dimensional
array
        for(int j = 0;j < img.cols;j++){

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

n[k]=pixel[j][1];k++;
//pass 3 Dimensional matrix instead of converting into 1 dimensional matrix.
           n[k]=pixel[j][0];k++;
            }
        }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/dev/attachments/20150601/283904fc/attachment.htm>


More information about the dev mailing list