Matlab中镜头畸变矫正

matlab中其实自己带了镜头畸变矫正的代码。
找了很久才发现原来兜兜转转还是回到原点

%% Correct Image for Lens Distortion
%
%%
close all
% Create a set of calibration images.
images = imageDatastore(fullfile(‘D:\matlab\bin\xiangmu\0008stere\left\use’));
%%
% Detect calibration pattern.
[imagePoints,boardSize] = detectCheckerboardPoints(images.Files);
%%
% Generate world coordinates of the corners of the squares. The square
% size is in millimeters.
squareSize = 29;
worldPoints = generateCheckerboardPoints(boardSize,squareSize);
%%
% Calibrate the camera.
I = readimage(images,1);
imageSize = [size(I,1),size(I,2)];
cameraParams = estimateCameraParameters(imagePoints,worldPoints, …
‘ImageSize’,imageSize);
%%
% Remove lens distortion and display results.
I = images.readimage(1);
J1 = undistortImage(I,cameraParams);
%%
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’);

你可能感兴趣的:(matlab,开发语言,图像处理)