barrel and pincushion lens distortion correction

I = LENSDISTORT(I, k)corrects for radially symmetric distortions
6.5K Downloads
Updated Fri, 31 Aug 2012 18:29:59 +0000

View License

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 [1].

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.

Parameters include:

'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
available are

'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.

Class Support
-------------
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.

Examples
--------
% read image
I = imread('cameraman.tif');

% Distort Image
I2 = lensdistort(I, 0.1);

% Display both images
imshow(I), figure, imshow(I2)

References
--------------
[1] http://en.wikipedia.org/wiki/Distortion_(optics), August 2012.

[2] Harri Ojanen, "Automatic Correction of Lens Distortion by Using
Digital Image Processing," July 10, 1999.

[3] G.Vassy and T.Perlaki, "Applying and removing lens distortion in post
production," year???

[4] http://www.mathworks.com/help/images/examples/creating-a-gallery-of-transformed-images.html, August 2012.

Created by Jaap de Vries, 8/31/2012
jpdvrs@yahoo.com

-----------------------------------------------------------------------%

Cite As

Jaap de Vries (2024). 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
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Read, Write, and Modify Image in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.1.0.0

8-31-2012 Made some spelling corrections and added an example.pdf file and example images

1.0.0.0