I = LENSDISTORT(I, k)corrects for radially symmetric distortions, where
I is the input image and k is the distortion parameter. lens distortion
can be one of two types: barrel distortion and pincushion distortion.
In "barrel distortion", image magnification decreases with
distance from the optical axis. The apparent effect is that of an image
which has been mapped around a sphere (or barrel). In "pincushion
distortion", image magnification increases with the distance from the
optical axis. The visible effect is that lines that do not go through the
centre of the image are bowed inwards, towards the centre of the image,
like a pincushion .
I = LENSDISTORT(...,PARAM1,VAL1,PARAM2,VAL2,...) creates a new image,
specifying parameters and corresponding values that control various aspects
of the image distortion correction. Parameter names case does not matter.
'bordertype' String that controls the treatment of the image
edges. Valid strings are 'fit' and 'crop'. By
default, 'bordertype' is set to 'crop'.
'interpolation' String that specifies the interpolating kernel
that the separable resampler uses. Valid
strings are 'cubic', 'linear' and 'nearest'. By
default, the 'interpolation' is set to 'cubic'
'padmethod' string that controls how the resampler
interpolates or assigns values to output elements
that map close to or outside the edge of the input
array. Valid strings are 'bound', circular',
'fill', 'replicate', and symmetric'. By
default, the 'padmethod' is set to 'fill'
'ftype' Integer between 1 and 4 that specifies the
distortion model to be used. The models
'ftype' = 1: s = r.*(1./(1+k.*r));
'ftype' = 2: s = r.*(1./(1+k.*(r.^2)));
'ftype' = 3: s = r.*(1+k.*r);
'ftype' = 4: s = r.*(1+k.*(r.^2));
By default, the 'ftype' is set to 4.
An input intensity image can be uint8, int8, uint16, int16, uint32,
int32, single, double, or logical. An input indexed image can be uint8,
uint16, single, double, or logical.
% read image
I = imread('cameraman.tif');
% Distort Image
I2 = lensdistort(I, 0.1);
% Display both images
imshow(I), figure, imshow(I2)
 http://en.wikipedia.org/wiki/Distortion_(optics), August 2012.
 Harri Ojanen, "Automatic Correction of Lens Distortion by Using
Digital Image Processing," July 10, 1999.
 G.Vassy and T.Perlaki, "Applying and removing lens distortion in post
Created by Jaap de Vries, 8/31/2012
Jaap de Vries (2021). barrel and pincushion lens distortion correction (https://www.mathworks.com/matlabcentral/fileexchange/37980-barrel-and-pincushion-lens-distortion-correction), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!