www.gusucode.com > vision 源码程序 matlab案例代码 > vision/CorrectAnImageForLensDistortionExample.m
%% Correct Image for Lens Distortion % %% % Create a set of calibration images. images = imageSet(fullfile(toolboxdir('vision'),'visiondata',... 'calibration','fishEye')); %% % Detect the calibration pattern. [imagePoints, boardSize] = detectCheckerboardPoints(images.ImageLocation); %% % Generate the world coordinates of the corners of the squares. The % square size is in millimeters. squareSize = 29; worldPoints = generateCheckerboardPoints(boardSize,squareSize); %% % Calibrate the camera. cameraParams = estimateCameraParameters(imagePoints,worldPoints); %% % Remove lens distortion and display the results. I = images.read(1); J1 = undistortImage(I,cameraParams); %% % Display the original and corrected images. figure; imshowpair(I,J1,'montage'); title('Original Image (left) vs. Corrected Image (right)'); J2 = undistortImage(I,cameraParams,'OutputView','full'); figure; imshow(J2); title('Full Output View');