# How is a lens distortion model performed? [duplicate]

So, as the title suggests, how is a lens distortion model (e.g. Brown-Conrady or pinhole camera model) applied on an image? I know it uses some calibration parameters (principal point's coords,focal length, tangential and radial distortion parameters), but how are they really used when a distortion removal algorithm is applied?

## 1 Answer

The model specifies a mapping from an ideal picture on a rectangular grid where the scene is projected in a rectilinear way to a distorted picture on another rectangular grid. It tells you where the pixels that should have appeared at some coordinate (x,y) can be found in the distorted image that you actually have. The problem is then that the gray values you need a some location in the corrected image can be found according to the mapping at some factional value, so you need to use interpolation.

Also, you need to take into account that one pixel in the corrected image will, in general, cover an area in the uncorrected image that is different from the area of one pixel in the uncorrected image. The gray value of the pixel in the corrected image is then determined by demanding that the total amount of light that falls in the area is the same as the light that fell in the corresponding area in the uncorrected image.

• So, if I got it correctly, the distortion is firstly applied on a grid and then it is inversed on the image? – Nikos Apr 7 '16 at 18:04
• @Nikos You can do with only the transform to the corrected image. If you consider the distorted images as consisting of pixels that are squares, then the mapping to the desired projection will map each square to a rotated and stretched square on the new grid. The gray value will scale inversely with the area of the square. You just apply the (inverse) mapping to the coordinates of the four corners of the pixels to see how it ends up on the new grid. This new grid is going to be filled with square pixels, you can give them the average gray value of the area they intercept. – Count Iblis Apr 7 '16 at 19:26