Home > CV, My Original Post > Matrix/Array Argument Passing in OpenCV

Matrix/Array Argument Passing in OpenCV

It is convenient to pass Mat to a function, which is one of the most frequently used argument passing in image processing. Actually, no real array elements (matrix) can be passed to a function, array pointers are the arguments that are passed to a function.

In OpenCV, Mat is an image, image is a Mat.

func(Mat src, Mat dst)
{
    ......
    //example
    for(int i=0, i<imax, i++)
       for(int j=0, j<jmax, j++)
          if(src.at<uchar>(i,j) == blabla)
              dst.at<uchar>(i,j) = blabla;
    ......
}

//another method used by opencv stock functions
func(Inputarry _src, Outputarry _dst)
{
    Mat src = _src.getmat();
    _dst.creat(src.size(), src.type());
    Mat dst = _dst.getmat();

    for(int i=0, i<imax, i++)
       for(int j=0, j<jmax, j++)
          if(src.at<uchar>(i,j) == blabla)
             dst.at<uchar>(i,j) = blabla;
    ......
}
Advertisements
Categories: CV, My Original Post
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: