letmaik / lensfunpy

📷 Lens distortion correction for Python, a wrapper for lensfun
https://pypi.python.org/pypi/lensfunpy
MIT License
145 stars 18 forks source link

Calculate new point after remapping of points #13

Open pskiselev opened 7 years ago

pskiselev commented 7 years ago

I looked through all the code and did't find formulas that calculate new coordinates after using method apply_geometry_distortion of Modifier class.

After undistorting the image, some pixels are lost, and i would like to know its location behind the image (e.g. point (-20; 20)).

Can I somehow match the pixels coordinates on the original frame and undistorted?

letmaik commented 7 years ago

As written offline, setting scale=1.0 when doing mod.initialize() should avoid cropping. Since that didn't work for you it would be interesting to figure out what's going on and whether scale is supposed to be used like that (it comes directly from the underlying liblensfun library). The image of interest was one with barrel distortion. So the goal is to undistort the image without loosing any parts of the image, which typically means introducing black areas.