Ask Your Question
1

Move pixel coordinate

asked 2017-05-25 04:32:35 -0500

Kenny Karnama gravatar image

Hi guys, i want to implement this formula :

formula

can anyone suggest function in opencv to do this ?

edit retag flag offensive close merge delete

Comments

berak gravatar imageberak ( 2017-05-25 04:46:29 -0500 )edit

sorry, the link can't be acessed.

Kenny Karnama gravatar imageKenny Karnama ( 2017-05-25 05:08:56 -0500 )edit

^^ thanks for notice, fixed now !

berak gravatar imageberak ( 2017-05-25 05:13:11 -0500 )edit

can i do shear transformation on x axis using remapping ? because i have used warpaffine, and it gives me wrong result.

Kenny Karnama gravatar imageKenny Karnama ( 2017-05-25 05:15:12 -0500 )edit

you can do any transformation with it (that's the beauty), you're not restricted to an affine or perspective conserving formula.

berak gravatar imageberak ( 2017-05-25 05:19:24 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2017-05-25 05:27:24 -0500

berak gravatar image

updated 2017-05-25 05:29:34 -0500

you can use remap for your shearing transformation:

const float a = 0.27; // it's a constant ?
Mat img = imread("../img/grid.jpg");
Mat_<Vec2f> prjMap(img.size());
for (int x=0; x<img.cols; x++) {
    for (int y=0; y<img.rows; y++) {
        float u = x - y * tan(a);
        float v = y;
        prjMap(y, x) = Vec2f(u,v);
    }
}
Mat projected;
remap(img, projected, prjMap, cv::Mat(), INTER_LINEAR);

input

output

edit flag offensive delete link more

Comments

why, you iterate with the column first ? Should it be the row first ?

Kenny Karnama gravatar imageKenny Karnama ( 2017-05-26 08:28:57 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-05-25 04:32:35 -0500

Seen: 524 times

Last updated: May 25 '17