镜头校正投影
消除使用鱼眼镜头或广角镜头拍摄的照片变形的最简单方法是什么? 我正在寻找一个参数很少的像素投影公式。 相机和镜头参数是未知的,因此用户必须直观地更改参数。 谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
ImageMagick 进行了精彩的讨论。 他们给出了他们使用的方程。
请注意,这不会以与 Photoshop CS6 相同的方式校正失真(即,您不能从 Adobe 镜头配置文件中获取系数并简单地将它们放入)。
Kamil 指出的论文 看起来是一篇出色的深入研究。
There is an excellent discussion from ImageMagick. They give the equation that they use.
Note that this does not correct distortion in the same way as Photoshop CS6 (i.e. you cannot take coefficients from the Adobe lens profiles and simply chuck them in).
The paper that Kamil points to seems like an excellent in-depth look.
我假设你可以使用透镜方程来做到这一点。
其中 f 是焦距(用户输入)。 使用放大方程,可以使用图像距离和物距的比率来适当调整图像的大小。 为了得到你真正想要的东西,你需要重构方程:
然后利用放大方程利用物体高度来调整大小:
您可能已经注意到,问题是您需要知道每个像素距相机的距离。 否则,它根本不起作用。 您可以向用户询问该信息,但这似乎不太可能,而且很痛苦。 我不知道还有什么其他方法可以做到这一点——镜头畸变是一种 3D 效果,而您获得的是 2D 信息。 您最多可以尝试以二维方式对其进行校正,但这会很困难,并且无法正常工作。
I would assume you could use the lens equation to do it.
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:
And then use the magnification equation to use the object height to resize:
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.
如果可能的话,您应该要求用户使用同一台相机拍摄参考图像(例如棋盘)的照片,然后使用该信息来分析镜头特性。 然后,该信息可用于消除同一相机拍摄的其他照片的变形。
为了实现,您可以使用神经网络/遗传算法。
If its possible you should ask the user to take a photograph of a reference image (a chess board for example) using the same camera and then use this information to analyze the lens characteristics. This information can then be used to un-warp the other photographs taken by the same camera.
For implementation you could use neural networks/genetic algorithms.
这里有一篇很好的论文,它提供了一些看起来不错的镜头畸变数学模型。 至少是这样。 我认为 SDX2000 的网格走上了正确的轨道。 我认为解决该问题的最常见方法是将图像映射到网格,然后允许应用扭曲参数来产生枕形和桶形失真。 请参阅 Lightroom 或 Photoshop 中的镜头畸变滤镜作为示例。
There is a good paper here that provides some decent looking mathematical models for lens distortion. It's at least. SDX2000 was kind of on the right track with the grid I think. I think the most common way to approach the problem is to map the image to a grid and then allow warping parameters to be applied to produce pincushion and barrel distortion. See the lens distortion filters in Lightroom or Photoshop as an example.