Radial distortion - from screenshot to map
Posted: 2016-10-22T03:11:43-07:00
Hi everybody!
I currently create a map for a video game. I don't have access to a rendered map from the levelmesh, so I flew high above the map and took a screenshot. In the game, an arrow indicates, where the player currently is. The position is taken from the coordinates in the mesh, and thus only correct directly below the point, where I took the screenshot. I am now looking for a distortion method, that can reverse this (radial) distortion that results from taking a screenshot, instead of an orthogonal map.
So far, I have some pairs of source-pixel Xs,Ys from the image and the corresponding "Real" Coordinates Xd,Yd and the origin Ox,Oy which is not distorted. I neglect the Z coordinate, which will give wrong results, but I hope, that the impact is relatively small.
I tried "-distort Barrel" and computet with 4 Coordinate-Pairs and the Origin the parameters A,B,C,D via the set of linear equations, I get when using the Rsource=Rdest^4*A+Rdest^3*B+Rdest^2*C+Rdest*D. A,B and C look quite reasonable, but D is -169, which distorts the image a lot. Furthermore I tried to use "-distort Polynomial" with 9 coordinate-pairs, which also distorts the image beyond what is reasonable. Generally I thought this should be a rather simple thing, since the distortion is a radial one, stronger the further I am away from the origin. Which should be a thing for linear regression with some coordinate pairs.
I appreciate your help!
Wolle
I currently create a map for a video game. I don't have access to a rendered map from the levelmesh, so I flew high above the map and took a screenshot. In the game, an arrow indicates, where the player currently is. The position is taken from the coordinates in the mesh, and thus only correct directly below the point, where I took the screenshot. I am now looking for a distortion method, that can reverse this (radial) distortion that results from taking a screenshot, instead of an orthogonal map.
So far, I have some pairs of source-pixel Xs,Ys from the image and the corresponding "Real" Coordinates Xd,Yd and the origin Ox,Oy which is not distorted. I neglect the Z coordinate, which will give wrong results, but I hope, that the impact is relatively small.
I tried "-distort Barrel" and computet with 4 Coordinate-Pairs and the Origin the parameters A,B,C,D via the set of linear equations, I get when using the Rsource=Rdest^4*A+Rdest^3*B+Rdest^2*C+Rdest*D. A,B and C look quite reasonable, but D is -169, which distorts the image a lot. Furthermore I tried to use "-distort Polynomial" with 9 coordinate-pairs, which also distorts the image beyond what is reasonable. Generally I thought this should be a rather simple thing, since the distortion is a radial one, stronger the further I am away from the origin. Which should be a thing for linear regression with some coordinate pairs.
I appreciate your help!
Wolle