Attempting to account for lens distortion using ” undistortedImage = undistortImage(originalIMage, cameraParams)
I am using the MATLAB Camera Calibtion App. and am attempting to mitgate lens distortion via post processing.
% Auto-generated by cameraCalibrator app on 01-May-2024
%——————————————————-
% Define images to process
imageFileNames = {‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001 deg 2024-04-30 17-35-57.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 00015 deg w 5 deg tilt 2024-04-30 17-37-59.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000115 deg w 5 deg tilt 2024-04-30 17-38-56.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000123 deg w 5 deg tilt 2024-04-30 17-40-03.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000130 deg w 5 deg tilt 2024-04-30 17-41-40.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000138 deg w 5 deg tilt 2024-04-30 17-42-51.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 6 deg w neg 15 deg tilt 2024-04-30 17-48-28.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 13 deg w neg 15 deg tilt 2024-04-30 17-50-12.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 20 deg w neg 15 deg tilt 2024-04-30 17-51-04.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 27 deg w neg 15 deg tilt 2024-04-30 17-51-46.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 33 deg w neg 15 deg tilt 2024-04-30 17-52-37.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 39 deg w neg 15 deg tilt 2024-04-30 17-53-44.png’,…
};
% Detect checkerboards in images
[imagePoints, boardSize, imagesUsed] = detectCheckerboardPoints(imageFileNames);
imageFileNames = imageFileNames(imagesUsed);
% Read the first image to obtain image size
originalImage = imread(imageFileNames{1});
[mrows, ncols, ~] = size(originalImage);
% Generate world coordinates of the corners of the squares
squareSize = 1.270000e+01; % in units of ‘millimeters’
worldPoints = generateCheckerboardPoints(boardSize, squareSize);
% Calibrate the camera
[cameraParams, imagesUsed, estimationErrors] = estimateCameraParameters(imagePoints, worldPoints, …
‘EstimateSkew’, true, ‘EstimateTangentialDistortion’, true, …
‘NumRadialDistortionCoefficients’, 3, ‘WorldUnits’, ‘millimeters’, …
‘InitialIntrinsicMatrix’, [], ‘InitialRadialDistortion’, [], …
‘ImageSize’, [mrows, ncols]);
% View reprojection errors
h1=figure; showReprojectionErrors(cameraParams);
% Visualize pattern locations
h2=figure; showExtrinsics(cameraParams, ‘CameraCentric’);
% Display parameter estimation errors
displayErrors(estimationErrors, cameraParams);
% For example, you can use the calibration data to remove effects of lens distortion.
undistortedImage = undistortImage(originalImage, cameraParams);
% See additional examples of how to use the calibration data. At the prompt type:
% showdemo(‘MeasuringPlanarObjectsExample’)
% showdemo(‘StructureFromMotionExample’)
JUst not sure how to get from is Highlghted code above to an answer. Is it just a subtraction of cameraParams – original image that wil tell us how to adjust for distotion in post processed maner please??I am using the MATLAB Camera Calibtion App. and am attempting to mitgate lens distortion via post processing.
% Auto-generated by cameraCalibrator app on 01-May-2024
%——————————————————-
% Define images to process
imageFileNames = {‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001 deg 2024-04-30 17-35-57.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 00015 deg w 5 deg tilt 2024-04-30 17-37-59.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000115 deg w 5 deg tilt 2024-04-30 17-38-56.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000123 deg w 5 deg tilt 2024-04-30 17-40-03.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000130 deg w 5 deg tilt 2024-04-30 17-41-40.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000138 deg w 5 deg tilt 2024-04-30 17-42-51.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 6 deg w neg 15 deg tilt 2024-04-30 17-48-28.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 13 deg w neg 15 deg tilt 2024-04-30 17-50-12.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 20 deg w neg 15 deg tilt 2024-04-30 17-51-04.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 27 deg w neg 15 deg tilt 2024-04-30 17-51-46.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 33 deg w neg 15 deg tilt 2024-04-30 17-52-37.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 39 deg w neg 15 deg tilt 2024-04-30 17-53-44.png’,…
};
% Detect checkerboards in images
[imagePoints, boardSize, imagesUsed] = detectCheckerboardPoints(imageFileNames);
imageFileNames = imageFileNames(imagesUsed);
% Read the first image to obtain image size
originalImage = imread(imageFileNames{1});
[mrows, ncols, ~] = size(originalImage);
% Generate world coordinates of the corners of the squares
squareSize = 1.270000e+01; % in units of ‘millimeters’
worldPoints = generateCheckerboardPoints(boardSize, squareSize);
% Calibrate the camera
[cameraParams, imagesUsed, estimationErrors] = estimateCameraParameters(imagePoints, worldPoints, …
‘EstimateSkew’, true, ‘EstimateTangentialDistortion’, true, …
‘NumRadialDistortionCoefficients’, 3, ‘WorldUnits’, ‘millimeters’, …
‘InitialIntrinsicMatrix’, [], ‘InitialRadialDistortion’, [], …
‘ImageSize’, [mrows, ncols]);
% View reprojection errors
h1=figure; showReprojectionErrors(cameraParams);
% Visualize pattern locations
h2=figure; showExtrinsics(cameraParams, ‘CameraCentric’);
% Display parameter estimation errors
displayErrors(estimationErrors, cameraParams);
% For example, you can use the calibration data to remove effects of lens distortion.
undistortedImage = undistortImage(originalImage, cameraParams);
% See additional examples of how to use the calibration data. At the prompt type:
% showdemo(‘MeasuringPlanarObjectsExample’)
% showdemo(‘StructureFromMotionExample’)
JUst not sure how to get from is Highlghted code above to an answer. Is it just a subtraction of cameraParams – original image that wil tell us how to adjust for distotion in post processed maner please?? I am using the MATLAB Camera Calibtion App. and am attempting to mitgate lens distortion via post processing.
% Auto-generated by cameraCalibrator app on 01-May-2024
%——————————————————-
% Define images to process
imageFileNames = {‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001 deg 2024-04-30 17-35-57.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 00015 deg w 5 deg tilt 2024-04-30 17-37-59.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000115 deg w 5 deg tilt 2024-04-30 17-38-56.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000123 deg w 5 deg tilt 2024-04-30 17-40-03.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000130 deg w 5 deg tilt 2024-04-30 17-41-40.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000138 deg w 5 deg tilt 2024-04-30 17-42-51.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 6 deg w neg 15 deg tilt 2024-04-30 17-48-28.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 13 deg w neg 15 deg tilt 2024-04-30 17-50-12.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 20 deg w neg 15 deg tilt 2024-04-30 17-51-04.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 27 deg w neg 15 deg tilt 2024-04-30 17-51-46.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 33 deg w neg 15 deg tilt 2024-04-30 17-52-37.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 39 deg w neg 15 deg tilt 2024-04-30 17-53-44.png’,…
};
% Detect checkerboards in images
[imagePoints, boardSize, imagesUsed] = detectCheckerboardPoints(imageFileNames);
imageFileNames = imageFileNames(imagesUsed);
% Read the first image to obtain image size
originalImage = imread(imageFileNames{1});
[mrows, ncols, ~] = size(originalImage);
% Generate world coordinates of the corners of the squares
squareSize = 1.270000e+01; % in units of ‘millimeters’
worldPoints = generateCheckerboardPoints(boardSize, squareSize);
% Calibrate the camera
[cameraParams, imagesUsed, estimationErrors] = estimateCameraParameters(imagePoints, worldPoints, …
‘EstimateSkew’, true, ‘EstimateTangentialDistortion’, true, …
‘NumRadialDistortionCoefficients’, 3, ‘WorldUnits’, ‘millimeters’, …
‘InitialIntrinsicMatrix’, [], ‘InitialRadialDistortion’, [], …
‘ImageSize’, [mrows, ncols]);
% View reprojection errors
h1=figure; showReprojectionErrors(cameraParams);
% Visualize pattern locations
h2=figure; showExtrinsics(cameraParams, ‘CameraCentric’);
% Display parameter estimation errors
displayErrors(estimationErrors, cameraParams);
% For example, you can use the calibration data to remove effects of lens distortion.
undistortedImage = undistortImage(originalImage, cameraParams);
% See additional examples of how to use the calibration data. At the prompt type:
% showdemo(‘MeasuringPlanarObjectsExample’)
% showdemo(‘StructureFromMotionExample’)
JUst not sure how to get from is Highlghted code above to an answer. Is it just a subtraction of cameraParams – original image that wil tell us how to adjust for distotion in post processed maner please?? undistortedimage MATLAB Answers — New Questions