opencv::remap() How to remap an Image to another Image with different size

Now I have Image A and I want to remap it to Image B which has a different size than Image A.

For each pixel coordinate (x, y), it has the coordinate (r, theta) on image B.

Can any one tell me how to realize it, preferably with sample code? Because I don't really understand the arguments map_x, map_y in the remap function.

Can somebody explain it for me? Thanks a lot!


remap decides where to map a pixel (i,j) by checking map_x(i,j) and map_y(i,j). At the end, your pixel (i,j) is mapped to (map_x(i,j),map_y(i,j)).

In your case, your pixel (x,y) should be mapped to (sqrt(x^2+y^2), atan(y/x)); so you need to populate map_x and map_y using these cart to polar equations:

for(int i = 0; i < src.rows; i++ )
    for(int j = 0; j < src.cols; j++ )
    {<float>(i,j) = sqrt(i^2 + j^2);<float>(i,j) = atan(j/i);

You may also want to look at cartToPolar

Need Your Help

javafx buttons some part of text hiding on hover

css javafx javafx-2

I am using javafx 2.2 for my desktop application.

Scikitlearn latent dirichlet allocation is giving empty topic


I am using the sklearn implementation of LDA for topic modelling.