After calibrating a camera and obtaining the camera matrix and optical distortion coefficient matrix of the camera, the calculated matrices can be used to perform correction of photo images captured using the same camera. The open source libraries EmguCV and OpenCV have the methods and functions to undistort images given the parameters determined previously. The following snippets show how to perform the correction.
The following code C# snippet extends the EmguCV Mat class to enable us to get and set values in the matrix by row and column indices.
The following code snippet is an example function that performs the correction to a list of JPEG images in a folder D:\Temp\.