Radial lens undistortion filtering
A common distortion which might occur when dealing with computer vision tasks involving wide-angle cameras is barrel distortion caused by a greater magnification at the center of the lens compared than the one at the edges.
Zhang, 1999
showed that the polynomial radial distortion model with two coefficients can be modeled as
we might consider a simpler approximation of this model for radial distortion Fitzgibbon, 2001
where \( r_u \) and \( r_d \) are the distances from the center of distortion in the undistorted and distorted images. \( \alpha \) is a constant specific to the lens type used.
In order to actually implement such an approximation a mapping between the original coordinates of a point in the image and the coordinates in a normalized \( [-1;+1] \) coordinate system is needed
\[x_n = (2x - w) / w \\ y_n = (2y - h) / h\]
(\( (x_n,y_n) \) stands for the normalized coordinates, \( w,h \) for width and height) and their inverse counterparts
\[x = \frac{(x_n + 1) * w}{2} \\ y = \frac{(y_n + 1) * h}{2}\]Implementing with OpenGL shaders
Given a simple textured quad which gets mapped to a radial distorted image, the filtering could be efficiently performed in the fragment shader
A sample WebGL implementation follows
References
-
Zhang Z. (1999). Flexible camera calibration by viewing a plane from unknown orientation
-
Andrew W. Fitzgibbon (2001). Simultaneous linear estimation of multiple view geometry and lens distortion