What is the simplest way to un-warp a photo made using fisheye or wide-angle lens? I'm looking a pixel projection formula that has few parameters. Camera and lens parameters will not be known, so user has to change the parameters visually. Thanks
4 回答
这里有一篇很好的论文,它为镜头失真提供了一些看起来不错的数学模型。至少是这样。我认为 SDX2000 的网格在正确的轨道上。我认为解决问题的最常见方法是将图像映射到网格,然后允许应用扭曲参数来产生枕形和桶形失真。以 Lightroom 或 Photoshop 中的镜头失真滤镜为例。
ImageMagick进行了精彩的讨论。他们给出了他们使用的方程式。
请注意,这并不能以与 Photoshop CS6 相同的方式校正失真(即,您不能从 Adobe 镜头配置文件中获取系数并简单地将它们放入)。
卡米尔指出的那篇论文似乎是一篇极好的深入研究。
I would assume you could use the lens equation to do it.
1/f = 1/object_distance + 1/image_distance
Where f is the focal length (the user input). The ratio of image distance and object distance could be used to resize the image appropriately, using the magnification equation. To get what you really want, then, you need to restructure the equation:
1/object_distance = 1/f - 1/image_distance
And then use the magnification equation to use the object height to resize:
-image_distance/object_distance = image_height/object_height
The catch, as you may have noticed, is that you need to know the distance each pixel is away from the camera. Otherwise, it simply doesn't work. You could ask the user for that information, but that seems unlikely, and painful. I don't know of any other way to do it-- lens distortion is a 3D effect, and you're given 2D information. At best you can attempt to correct it two-dimensionally, but this will be difficult, and won't work properly.
如果可能,您应该要求用户使用同一台相机拍摄参考图像(例如棋盘)的照片,然后使用此信息来分析镜头特性。然后,此信息可用于对同一相机拍摄的其他照片进行反变形。
对于实现,您可以使用神经网络/遗传算法。