Lens Distortion Effects - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

Lens Distortion Effects

Description:

http://www.pauck.de/marco/photo/stuff/peleng_fisheye/peleng_fisheye.html ... function calls during raster scanning: overhead due to context switching ... – PowerPoint PPT presentation

Number of Views:152
Avg rating:3.0/5.0
Slides: 28
Provided by: claudecch
Category:

less

Transcript and Presenter's Notes

Title: Lens Distortion Effects


1
Imaging and Special Effects CE00376-2
Fac. of Comp., Eng. Tech. Staffordshire
University
Lens Distortion Effects
Dr. Claude C. Chibelushi
2
Outline
  • Introduction
  • Transformation function
  • Linear magnification
  • Piecewise linear distortion
  • Non-linear distortion
  • Range problem
  • Scaling of 2D image
  • Orthogonal coordinate transformation
  • Radial coordinate transformation
  • Performance issues
  • Summary

3
Introduction
  • Lens distortion effects image change by
    stretching and shrinking
  • variable scaling coefficient applied to whole or
    part of image
  • transformation of pixel position by varying
    amounts
  • requires position transformation function
  • type of function determines lens distortion
    effect wide variety of functions or function
    combinations
  • scaling relative to chosen reference

4
Introduction
  • Geometric transformations (revisited)
  • To solve problem of possible gaps in target image
    caused by magnification
  • scan pixel position in target image
  • compute corresponding position in source image
  • apply inverse of desired transformation

5
Transformation function
Linear magnification Image scaling
(revisited) for (row 0 row lt IM_HEIGHT
row) for (col 0 col lt IM_WIDTH col)
srcRow row / rowScale // inverse
scaling srcCol col / colScale if (
(srcRow gt 0 srcRow lt SRCIM_HEIGHT)
(srcCol gt 0 srcCol lt SRCIM_WIDTH)
) trgtImagerowcol srcImagesrcRowsrcCol
else trgtImagerowcol 255 //
arbitrary default
To be replaced by relevant inverse transformation
function for lens distortion
Assumption positive scaling factors
6
Transformation function
  • Linear magnification
  • Position transformation function is straight line
    with slope greater than 1
  • e.g. function for magnification by two
  • t 2 s or s t / 2

position in source image
position in target image
slope
7
Transformation function
  • Piecewise linear distortion
  • Position-dependent image scaling
  • neighbouring image segments scaled using
    different linear functions
  • typically combination of functions with slope
    greater than 1 (magnification) and slope less
    than 1 (demagnification)
  • so that image size increase due to stretching
    balanced by size decrease due to shrinking

8
Transformation function
  • Example of non-linear distortion

http//www.pauck.de/marco/photo/stuff/peleng_fishe
ye/peleng_fisheye.html
http//www.omnitech.com/graphics/fisheye_macbeth.j
pg
9
Transformation function
  • Non-linear distortion
  • Typical non-linear distortion fish-eye lens
    effect
  • focus on region of interest
  • magnification near centre of simulated lens (i.e.
    centre of scaling)
  • demagnification (minification) near boundary of
    simulated lens

10
Transformation function
  • Non-linear distortion
  • Position-dependent image scaling using non-linear
    function
  • function whose slope is not constant
  • e.g. sine transformation function
  • t sin( s ) or s arcsin( t )

Range problem s might not be in legal range of
angles expected by sin
Range problem output range of sin not same as
expected range of t
11
Transformation function
  • Range problem
  • Solution map value to fit into expected range
  • Hence process for applying transformation from
    target to source position is
  • convert target position to fit into input range
    of function
  • apply inverse function
  • convert function output to fit into range of
    source positions

12
Transformation function
  • Range problem
  • Range fitting function similar to histogram
    stretch function (see lecture on Contrast
    Enhancement)
  • for stretching values (old value v) from range
    minold, maxold to minnew, maxnew, about
    reference (ref)

1. Value shift
2. Value scaling
3. Value shift
13
Transformation function
  • Pseudo-code for position transformation
  • // calculate source value for given target value
  • scale(t)
  • inVal fit2Range(t, tRange, inValRange, tRef,
    inValRef)
  • outVal inverseFunction(inVal) // use suitable
    function
  • s fit2Range(outVal, outValRange, sRange,
    outValRef, sRef)
  • return s // return source value
  • // convert value to fit into given range
  • fit2Range(oldVal, oldRange, newRange, oldRef,
    newRef)
  • newVal ((oldVal - oldRef) newRange /
    oldRange) newRef
  • return newVal

14
Scaling of 2D image
  • Scaling of 2D image often based on 1D
    transformation function
  • effect depends on how function is applied to x
    and y (i.e. column and row) coordinates of pixel
  • coordinate transformation can be orthogonal,
    radial, ...
  • for speed, function output values can be
    pre-calculated
  • stored in look-up table

15
Scaling of 2D image
  • Orthogonal coordinate transformation
  • x and y coordinates transformed independently
  • Preserves horizontal and vertical lines

16
Scaling of 2D image
  • Pseudo-code for orthogonal coordinate
    transformation
  • for (row 0 row lt IM_HEIGHT row)
  • for (col 0 col lt IM_WIDTH col)
  • // inverse transformation of row and col
  • srcRow scale(row)
  • srcCol scale(col)
  • if ( (srcRow gt 0 srcRow lt SRCIM_HEIGHT)
  • (srcCol gt 0 srcCol lt SRCIM_WIDTH) )
  • trgtImagerowcol srcImagesrcRowsrcCol
  • else
  • trgtImagerowcol 255 // arbitrary
    default

17
Scaling of 2D image
  • Radial coordinate transformation
  • x and y coordinates transformed in step
  • so that target and source position lie along
    radial line from lens centre
  • Preserves lines that radiate from centre of
    scaling

18
Scaling of 2D image
  • Radial coordinate transformation
  • Process
  • polar coordinate (i.e. radius relative to centre
    of lens) calculated from x and y coordinates
  • radius transformed using transformation function
  • x and y coordinates scaled to match new radius
  • pixel copied to calculated position

19
Scaling of 2D image
  • Radial coordinate transformation
  • Radial distance r between position (x, y) and
    lens centre (xc, yc)

Pythagoras theorem
20
Scaling of 2D image
  • Radial coordinate transformation
  • Scale x and y coordinates to match new radius

Similar triangles formula
, hence
and
21
Scaling of 2D image
  • Radial coordinate transformation
  • Calculation of x and y coordinates
  • replace h and w by (y - yc) and (x - xc),
    respectively
  • rearrange formulas to get unknown variables
  • these are xs and ys, for inverse transformation

22
Scaling of 2D image
  • Pseudo-code for radial coordinate transformation
  • // scale coordinate so that transformed point
    lies along
  • // radius from centre of scaling to untransformed
    position
  • radialScaleCoord(radius, oldRadius, oldCoord,
    centreCoord)
  • // inverse transformation of coordinate
  • coord ((oldCoord - centreCoord) radius /
    oldRadius)
  • centreCoord
  • return coord

23
Scaling of 2D image
  • Pseudo-code for radial coordinate transformation
    (ctd.)
  • for (row 0 row lt IM_HEIGHT row)
  • for (col 0 col lt IM_WIDTH col)
  • radius sqrt( square(row - magCentreRow)
  • square(col - magCentreCol) )
  • // inverse transformation of radius
  • srcRadius scale(radius)
  • // scale row and col radially
  • srcRow radialScaleCoord(srcRadius, radius,
    row, magCentreRow)
  • srcCol radialScaleCoord(srcRadius, radius,
    col, magCentreCol)
  • if ( (srcRow gt 0 srcRow lt SRCIM_HEIGHT)
  • (srcCol gt 0 srcCol lt SRCIM_WIDTH) )
  • trgtImagerowcol srcImagesrcRowsrcCol
  • else
  • trgtImagerowcol 255 // arbitrary
    default

24
Scaling of 2D image
  • Performance issues
  • Aliasing artefacts arise when high resolution
    pattern (e.g. image, sound) changed into lower
    resolution pattern
  • typical artefacts
  • in still images jagged (jaggies) blocky, or
    Moiré patterns
  • in moving images wagon-wheel effect, pixel
    popping (or crawlies)

25
Scaling of 2D image
  • Performance issues
  • To minimise aliasing artefacts due to
    magnification
  • source image should have higher resolution than
    target image
  • source resolution higher than target resolution
    times maximum slope of transformation function
  • apply anti-aliasing technique / filter

26
Scaling of 2D image
  • Performance issues
  • Pseudo-code given earlier not optimised for
    performance, e.g.
  • repeated function calls during raster scanning
    overhead due to context switching associated with
    function call
  • solution minimise number of functions called
    repeatedly
  • repeated recalculation of fixed values in
    functions e.g. ratio of value ranges,
    coordinates relative to lens centre
  • solution pre-calculate and store fixed values
  • repeated costly operations e.g. square root,
    sine
  • solution pre-calculate and store in look-up table

27
Summary
  • Lens distortion effects
  • image change by stretching and shrinking whole or
    part of image
  • Image scaling based on position transformation
    function
  • function may be linear, piecewise linear,
    non-linear
  • scaling of 2D image using 1D function
  • coordinate transformation can be orthogonal,
    radial, ...
Write a Comment
User Comments (0)
About PowerShow.com