Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

you can use opencv's builtin remapping, but you have to calculate the mapping coods manually, similar to this:

Mat_<float> map_x(img.size()), map_y(img.size());
for( int i = 0; i < map_x.rows; i++ )
{
    for( int j = 0; j < map_x.cols; j++ )
    {
           map_x(i,j) = a0 + a1*j + a2*i + a3*j*i + a4*j*j + a5*i*i;
           map_y(i,j) = b0 + b1*j + b2*i + b3*j*i + b4*j*j + b5*i*i;
    }
}

Mat dst;
remap(img, dst, map_x, map_y, INTER_LINEAR, BORDER_CONSTANT, Scalar(0, 0, 0) );

you can use opencv's builtin remapping, to warp the image, but you have to calculate the mapping coods manually, similar to this:

Mat_<float> map_x(img.size()), map_y(img.size());
for( int i = 0; i < map_x.rows; i++ )
{
    for( int j = 0; j < map_x.cols; j++ )
    {
           map_x(i,j) = a0 + a1*j + a2*i + a3*j*i + a4*j*j + a5*i*i;
           map_y(i,j) = b0 + b1*j + b2*i + b3*j*i + b4*j*j + b5*i*i;
    }
}

Mat dst;
remap(img, dst, map_x, map_y, INTER_LINEAR, BORDER_CONSTANT, Scalar(0, 0, 0) );

you can use opencv's builtin remapping to warp the image, but you have to calculate the mapping coods coords manually, similar to this:

Mat_<float> map_x(img.size()), map_y(img.size());
for( int i = 0; i < map_x.rows; i++ )
{
    for( int j = 0; j < map_x.cols; j++ )
    {
           map_x(i,j) = a0 + a1*j + a2*i + a3*j*i + a4*j*j + a5*i*i;
           map_y(i,j) = b0 + b1*j + b2*i + b3*j*i + b4*j*j + b5*i*i;
    }
}

Mat dst;
remap(img, dst, map_x, map_y, INTER_LINEAR, BORDER_CONSTANT, Scalar(0, 0, 0) );