image warping - introduction - computer graphics...

22
Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 1 / 22 Image warping ˗ introduction © 1997-2015 Josef Pelikán CGG MFF UK Praha [email protected] http://cgg.mff.cuni.cz/~pepca/

Upload: hatuong

Post on 03-Apr-2018

221 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 1 / 22

Image warping ˗introduction

© 1997-2015 Josef Pelikán

CGG MFF UK Praha

[email protected]

http://cgg.mff.cuni.cz/~pepca/

Page 2: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 2 / 22

Warping .. image deformation

texture mapping in 3D rendering (after rasterization)– perspective distortion, mapping textures to arbitrary shapes

correction of geometric distortion (digital image acquirement)– satellite and aerial photography– scanning of deformed documents

special effects in TV, film and advertisement

Page 3: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 3 / 22

Mathematical model

„image function”

f U R Rn: 2

x

y

U

position onthe plane

f x y a a an: , , ,... 1 2

image attributes (color, transparency)

Page 4: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 4 / 22

Spatial discretization

Digitized raster image:

I m n Rn: .. ..0 1 0 1

Digitization using filter d:

I i j f x y d x i y j dx dyf

R

, , , 2

d .. device characteristics (optical system, CCD element)

Page 5: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 5 / 22

Digital image reproduction

Reconstruction of a discrete image:

r .. output device characteristics (impulse response)

f x y I i j r i x j yrf

j

n

i

m

, , ,

0

1

0

1

.. we need fr to be similar to f (in frequency range defined by the Nyquist law)

Page 6: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 6 / 22

Geometric transform

g R R: 2 2

x

y

U

But what about raster images?

f x y f g x y, ,

x

yf f’

g

f g u v f u v 1 , ,

G I If f

Page 7: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 7 / 22

digitization = sampling– digitizing filter = Dirac delta

attributes (color) of transformed pixel computed by approximation or interpolation– inverse transform function g-1 is needed

„rounding“, polynomial interpolation– bilinear to bicubic interpolation/approximation is

sufficient

Transform with interpolation

Page 8: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 8 / 22

Interpolation in source coord. system

ig-1(u,v)

i+1

i+1

j

Page 9: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 9 / 22

pixel-area model– digitizing filter has areal support (e.g. box or conical

filter)

source pixels are projected to target coordinate system– only g is needed

suitable also for contractive transforms– isometric transform image is blurred– big contraction high computing time (speedup needed)

Transform with filtering

Page 10: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 10 / 22

Transform with filtering

g(i,j)

u u+1

v+1

v

v-1u-1

Page 11: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 11 / 22

pyramidal representation of the source image (hierarchy)– preprocessing = pre-filtering

useful mostly for transforms with big contraction – substantial speedup– used mostly for texture mapping on the GPU (distant

objects)

compact storage– only 4/3 size of original RGB image

„MIP map“ (multum in parvo)

Page 12: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 12 / 22

„MIP map”

R0G0

B0

G1 R1

B1

G2 R2

B2

Page 13: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 13 / 22

Multi-pass algorithms

transform is factored into several consecutive steps– each step works either on rows or on columns

of an image

faster computation– simpler filtering– two 1D filters are faster than a 2D one

bottleneck problem– partial mapping is highly contractive or even non-injective

Page 14: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 14 / 22

Two-pass rotation

f

g

[x,y]

[u,v][r,s]

[u,v] = f(x,y) = [f1(x,y),y]

[r,s] = g(u,v) = [u,g1(u,v)] = [f1(x,y),g1(f1(x,y),v)]

Page 15: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 15 / 22

Derivation

First transform f:

u f x y v y 1 ,

Second transform g:

r u f x y s g u v g f x y y 1 1 1 1, , , ,

Target transform (rotation by ):

r x ys x y

cos sinsin cos

Page 16: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 16 / 22

g u v x y x v1 , sin cos sin cos

Derivation

g u v u v1 , tan sec

Horizontal shear for the first pass:

f x y x y1 , cos sin

Vertical shear for the second pass:

u f x v x vx u v

1 , cos sinsin cos

Page 17: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 17 / 22

cos sin

sin cos

tan

sin

tan

1 2

0 1

1 0

1

1 2

0 1

Three-pass rotation

Rotation matrix factoring:

sufficient for angles: 2 2

Page 18: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 18 / 22

Arbitrary angle

multi-pass methods cannot be used for wide range of angles. Suitable angle ranges:-45o 45o for two-pass rotation

-90o 90o for three-pass rotation

auxiliary rotation (multiple of 90o)– simple, fast– no image degradation

Page 19: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 19 / 22

General separable transform

Separable transform:

if (u,v) such that

f x y h x y

g u v h u v v

1 1

1 2

, ,

, , ,

h x y h x y h x y g f x y

f x y f x y y

g u v u g u v

, , , , ,

, , ,

, , ,

1 2

1

1

x u v ,

Page 20: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 20 / 22

Image degradation

Inapplicable areas: low values of the derivative

Sometimes even the inverse function could notbe defined (u,v) !

h x y

x1 ,

or high values of the derivative

g u v

v1 ,

concurrent processing of images I and IT

Page 21: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 21 / 22

Optimized algorithm

concurrent processing of original I and transposed IT image– both branches use the same method (two-pass algorithm

using separable transforms h and hT)

result pixels are composed from h(I) and (hT(IT))T

– comparing degradation pixel by pixel

even for „non-injective“ deformations!– image „folding”..

Page 22: Image warping - introduction - Computer Graphics …cgg.mff.cuni.cz/~pepca/lectures/pdf/2d-03-warping.en.pdfComputer Graphics, Principles and Practice, 815-832 J. Gomes et al.: Warping

Warping 2015 © Josef Pelikán, http://cgg.mff.cuni.cz/~pepca 22 / 22

The End

More info:

J. Foley, A. van Dam, S. Feiner, J. Hughes: Computer Graphics, Principles and Practice, 815-832

J. Gomes et al.: Warping and Morphing of Graphical Objects, Course Notes - SIGGRAPH’95