 # Homography (mathematic) question

Hello everyone.

I have a small question that makes me crazy. I hope that someone, smartest than me, could help me to get out of it :).

I will try to explain my problem.

I compute the homography H between images A and B. I use findHomography for that.
No problem, it works well.
No I want to apply H. But in fact I want to apply H’ that corresponds to the Homography of the transformation between A and B’ without recomputing it. And B’ is just a flip of B. B’ is read bottom to up while B is read top down.

So I would like to know which transformation I need to apply to H.

At the beginning I was thinking that something like:

``````/* modify matrix for reverse Y axis */

Mat F = Mat::eye(3, 3, CV_64FC1);
F.at<double>(1,1) = -1.0;
F.at<double>(1,2) = height - 1.0;
H = F * H * F.inv();|
``````

But it won’t work for image that have different size.
Well, I’m stuck with this problem. I know I just show you a small piece of code (code is too big to write a small standalone example) but as it is a mathematics issue, maybe someone could help.

So. Someone helped me … I think she found the solution. I need two flip matrix to handle the two different sizes:

``````    Mat F1 = Mat::eye(3, 3, CV_64FC1);
F1.at<double>(1,1) = -1.0;
F1.at<double>(1,2) = source_ry - 1.0;

Mat F2 = Mat::eye(3, 3, CV_64FC1);
F2.at<double>(1,1) = -1.0;
F2.at<double>(1,2) = target_ry - 1.0;

H = F2.inv() * H * F1;
``````

Warning, I’m not sure if I got you right!

F is the flip transformation, so

``````B' = B * F
``````

H is the homography so

``````B = A * H
``````

How to get B’ from A:

``````B' = B * F = A * H * F = A * H'
``````

Let’s

``````H' = H * F
``````

Of course you will have to rewrite the formulas if you change the factors order, like

``````B' = F * B  instead of B' = B * F
``````

Does it make sense?

Hello @Alejandro_Silvestri .