lookijeans.blogg.se

Mapping 2d coordinates into curved space
Mapping 2d coordinates into curved space




  1. #Mapping 2d coordinates into curved space code#
  2. #Mapping 2d coordinates into curved space free#

We know the line we are projecting starts at the origin and crosses the image plane at xim. Here is a quick diagram of the terminology. Now we know all the parameters of the cylinder we move on to step 2, project lines from the camera, through the image plane at xim to the cylinder at xc. If the edge of the cylinder is going to touch the edge of the image plane which has a width w and a focal length f then omega^2+(f-z0)^2 = r^2 //define omega = width/2, it cleans it up a bit The equation of a circle in the zx plane is x^2+(z-z0)^2 = r^2Īssuming the center of the circle lies on the z axis.

#Mapping 2d coordinates into curved space free#

If that is true, then the the 2 free parameters you can choose are cylinder radius and focal length. First of all, I am assuming that you want to guarantee that your cylinder touches your image at the edges. Keeping track of everything can be a little tricky so I will try to use consistent terminology.

  • Use an orthographic projection to move that ray back to the image plane (just means drop the z component).
  • Project a ray from the camera, passing through each point in the new image and find its x,y,z coordinates on the cylinder.
  • It actually works much better if you check for every pixel in your new image where it appeared in the old image and set its colour. You might first think that you want to take every pixel in your original image and move it into your new image. The first trick is that we actually want to represent this process backwards. When the points are projected back notice they no longer form a flat line on the image plane, there is a curve because of the z coordinate of the cylinder varying with x. In your case the cylinder is touching the image plane at the left and right edges so no shrink occurs. Notice in this case that the entire image shrinks because all parts of the cylinder had a greater z coordinate than the image plane. Then those points are projected with perspective back onto the image plane. The first step is to do an orthographic projection moving the image onto the curved surface. Say we have a flat image with a concave cylinder sitting in front of it. To start, it is important to understand why exactly the image warps the way it does. I like this problem because the projection involved is interesting but the math can still be solved by hand without too much difficulty.

    #Mapping 2d coordinates into curved space code#

    This is an answer in 2 parts, the math and the code Math






    Mapping 2d coordinates into curved space