cv.undistort - MATLAB File Help
cv.undistort

Transforms an image to compensate for lens distortion

dst = cv.undistort(src, cameraMatrix, distCoeffs)
dst = cv.undistort(..., 'OptionName', optionValue, ...)

Input

Output

Options

The function transforms an image to compensate radial and tangential lens distortion.

The function is simply a combination of cv.initUndistortRectifyMap (with unity R) and cv.remap (with bilinear interpolation). See the former function for details of the transformation being performed.

Those pixels in the destination image, for which there is no correspondent pixels in the source image, are filled with zeros (black color).

A particular subset of the source image that will be visible in the corrected image can be regulated by NewCameraMatrix. You can use cv.getOptimalNewCameraMatrix to compute the appropriate NewCameraMatrix depending on your requirements.

The camera matrix and the distortion parameters can be determined using cv.calibrateCamera. If the resolution of images is different from the resolution used at the calibration stage, fx, fy, cx and cy need to be scaled accordingly, while the distortion coefficients remain the same.

See also