www.gusucode.com > vision 源码程序 matlab案例代码 > vision/RemoveDistortionFromAnImageExample.m

    %% Use the vision.CameraParameters Object to Remove Distortion from an Image
% This example shows you how to use the camera calibration functions to
% remove distortion from an image. The example creates a
% vision.CameraParameters object manually, but in practice, you would use
% the estimateCameraParameters or the cameraCalibrator app to derive the
% object.
%% Create a vision.CameraParameters object manually.
% IntrinsicMatrix = [715.2699   0       0;
%                       0     711.5281  0;
%                  565.6995  355.3466  1];
% radialDistortion = [-0.3361 0.0921];
% cameraParameters = vision.CameraParameters('IntrinsicMatrix', IntrinsicMatrix, 'RadialDistortion', radialDistortion);
% %% Remove distortion from the images.
% I = imread(fullfile(matlabroot, 'toolbox', 'vision', 'visiondata', 'calibration', 'fishEye', 'image01.jpg'));
% J = undistortImage(I, cameraParameters);
% %% Display the original and the undistorted images.
% figure; imshowpair(imresize(I, 0.5), imresize(J, 0.5), 'montage'); 
% title('Original Image (left) vs. Corrected Image (right)');

% Copyright 2015 The MathWorks, Inc.