Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

copy small part of mat to another

I can't figure how to copy a part of mat to another mat. ( or to itself)

I want for example to copy (or to keep) only the first row of srcMat.

I am using :

    for ( int x = 0; x < height; x++ )
    {
        for ( int y = 0; y < width; y++ )
        {
            destMat = scrMat.at<float>(x,0);
        }
    }

I am not sure about using:

            srcMat.copyTo( destMat( Rect( 0, x, srcMat.cols, srcMat.rows ) ) );

copy small part of mat to another

I can't figure how to copy a part of mat to another mat. ( or to itself)

I want for example to copy (or to keep) only the first row of srcMat.

I am using :

    for ( int x = 0; x < height; x++ )
    {
        for ( int y = 0; y < width; y++ )
        {
            destMat = scrMat.at<float>(x,0);
           // or destMat.at<float>(x,y) = scrMat.at<float>(x,0);
        }
    }

I am not sure about using:

            srcMat.copyTo( destMat( Rect( 0, x, srcMat.cols, srcMat.rows ) ) );

copy small part of mat to another

I can't figure how to copy a part of mat to another mat. ( or to itself)

I want for example to copy (or to keep) only the first row of srcMat.

I am using :

    for ( int x = 0; x < height; x++ )
    {
        for ( int y = 0; y < width; y++ )
        {
            destMat = scrMat.at<float>(x,0);
scrMat.at<float>(0,y);
           // or destMat.at<float>(x,y) = scrMat.at<float>(x,0);
scrMat.at<float>(0,y);
        }
    }

I am not sure about using:

            srcMat.copyTo( destMat( Rect( y, 0, x, srcMat.cols, srcMat.rows ) ) );
click to hide/show revision 4
retagged

copy small part of mat to another

I can't figure how to copy a part of mat to another mat. ( or to itself)

I want for example to copy (or to keep) only the first row of srcMat.

I am using :

    for ( int x = 0; x < height; x++ )
    {
        for ( int y = 0; y < width; y++ )
        {
            destMat = scrMat.at<float>(0,y);
           // or destMat.at<float>(x,y) = scrMat.at<float>(0,y);
        }
    }

I am not sure about using:

            srcMat.copyTo( destMat( Rect( y, 0, srcMat.cols, srcMat.rows ) ) );