cv.undistort - MATLAB File Help |
Transforms an image to compensate for lens distortion
dst = cv.undistort(src, cameraMatrix, distCoeffs)
dst = cv.undistort(..., 'OptionName', optionValue, ...)
A = [fx 0 cx; 0 fy cy; 0 0 1]
.[k1,k2,p1,p2,k3,k4,k5,k6,s1,s2,s3,s4,taux,tauy]
of 4, 5, 8, 12 or 14
elements. If the vector is empty, the zero distortion coefficients are
assumed.src
.cameraMatrix
but you may additionally scale and shift the
result by using a different matrix. Not set by defaultThe 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.