IMAGE WARPING Vuong Le Dept. Of ECE University of Illinois ECE - - PowerPoint PPT Presentation

image warping
SMART_READER_LITE
LIVE PREVIEW

IMAGE WARPING Vuong Le Dept. Of ECE University of Illinois ECE - - PowerPoint PPT Presentation

IMAGE WARPING Vuong Le Dept. Of ECE University of Illinois ECE 417 Spring 2013 With some slides from Alexei Efros, Steve Seitz, Jilin Tu, and Hao Tang Content Introduction Parametric warping Barycentric coordinates


slide-1
SLIDE 1

IMAGE WARPING

Vuong Le

  • Dept. Of ECE

University of Illinois

ECE 417 – Spring 2013 With some slides from Alexei Efros, Steve Seitz, Jilin Tu, and Hao Tang

slide-2
SLIDE 2

Content

  • Introduction
  • Parametric warping
  • Barycentric

coordinates

  • Interpolation
  • MP6
slide-3
SLIDE 3

Content

  • Introduction
  • Parametric warping
  • Barycentric

coordinates

  • Interpolation
  • MP6
slide-4
SLIDE 4

Image Warping

image filtering: change range of image g(x) = T(f(x))

f x

T

g x f x

T

g x

image warping: change domain of image g(x) = f(T(x))

slide-5
SLIDE 5

Image Warping

image filtering: change range of image g(x) = T(f(x))

T T

f f g g

image warping: change domain of image g(x) = f(T(x))

slide-6
SLIDE 6

Global parametric image warping

Examples of parametric warps:

translation rotation aspect affine perspective cylindrical

slide-7
SLIDE 7

Piecewise parametric image warping

  • Define a mesh of small shape units: triangles/quadrangles
  • Apply different transformations for different units

M1 M2

slide-8
SLIDE 8

Non-parametric warping

  • Move control points of a grid
  • Use thin plate splines to produces a smooth vector field
slide-9
SLIDE 9

Image morphing

slide-10
SLIDE 10
slide-11
SLIDE 11

Photoshop examples

slide-12
SLIDE 12

Photoshop examples

slide-13
SLIDE 13

Content

  • Introduction
  • Parametric warping
  • Barycentric

coordinates

  • Interpolation
  • MP6
slide-14
SLIDE 14

Parametric image warping

Transformation T is a coordinate-changing machine: What does it mean that T is parametric?

° can be described by just a few numbers (parameters)

How to represent global and local transforms?

° Global: T Is the same for any point p in the image ° Local: T can be different at different location

Let’s try to represent T as a matrix: p’ = Mp T p = (x,y) p’ = (x’,y’)

      =       y x y x M ' '

slide-15
SLIDE 15

Scaling

Scaling operation: Or, in matrix form:

by y ax x = = ' '             =       y x b a y x ' '

scaling matrix S

slide-16
SLIDE 16

2-D Rotation

θ

(x, y) (x’, y’)

x’ = x cos(θ) - y sin(θ) y’ = x sin(θ) + y cos(θ)

( ) ( ) ( ) ( )

            − =       y x y x θ θ θ θ cos sin sin cos ' '

R

slide-17
SLIDE 17

Shearing in x

 The y coordinates are unaffected, but the x coordinates are translated linearly with y  That is

' * '

y

x x sh y y y = + =

' 1 ' 1

y

x sh x y y       =            

slide-18
SLIDE 18

Shearing in y

' ' *

x

x x y sh x y = = +

1 ' 1 '

x

x x sh y y       =            

slide-19
SLIDE 19

2x2 Matrices

What types of transformations can be represented with a 2x2 matrix? 2D Shear?

y x sh y y sh x x

y x

+ = + = * ' * '

            =       y x sh sh y x

y x

1 1 ' '

2D Mirror about Y axis?

y y x x = − = ' '

           − =       y x y x 1 1 ' '

2D Mirror over (0,0)?

y y x x − = − = ' '

            − − =       y x y x 1 1 ' '

slide-20
SLIDE 20

2x2 Matrices

What types of transformations can be represented with a 2x2 matrix? 2D Translation?

y x

t y y t x x + = + = ' '

Only linear 2D transformations can be represented with a 2x2 matrix

NO!

slide-21
SLIDE 21

All 2D Linear Transformations

Linear transformations are combinations of …

° Scale, ° Rotation, ° Shear, and ° Mirror

Properties of linear transformations:

° Origin maps to origin ° Lines map to lines ° Parallel lines remain parallel ° Distance or length ratios are preserved on parallel lines ° Ratios of areas are preserved

            =       y x d c b a y x ' '

slide-22
SLIDE 22

Homogeneous Coordinates

Q: How can we represent translation as a 3x3 matrix?

y x

t y y t x x + = + = ' '

slide-23
SLIDE 23

Homogeneous Coordinates

Q: How can we represent translation as a 3x3 matrix? A: Using the rightmost column:

          = 1 1 1

y x

t t ranslation T

y x

t y y t x x + = + = ' '

' 1 ' 1 * 1 1 1

x y

x t x y t y             =                  

slide-24
SLIDE 24

Homogeneous Coordinates

Add a 3rd coordinate to every 2D point

° (x, y, w) represents a point at location (x/w, y/w) ° (x, y, 0) represents a point at infinity ° (0, 0, 0) is not allowed

  • Convenient coordinate system to represent many useful

transformations

  • (aw, bw, w) represent the same 2D point for any value of w

1 2 1 2

(2,1,1) or (4,2,2) or (6,3,3) x y

slide-25
SLIDE 25

Basic 2D Transformations

Basic 2D transformations as 3x3 matrices

                    Θ Θ Θ − Θ =           1 1 cos sin sin cos 1 ' ' y x y x                     =           1 1 1 1 1 ' ' y x t t y x

y x

                    =           1 1 1 1 1 ' ' y x sh sh y x

y x

Translate Rotate Shear

                    =           1 1 1 ' ' y x s s y x

y x

Scale

slide-26
SLIDE 26

Affine Transformations

Affine transformations are combinations of …

° Linear 2D transformations, and ° Translations

Properties of affine transformations:

° Origin does not necessarily map to origin ° Lines map to lines ° Parallel lines remain parallel ° Length/distance ratios are preserved on parallel lines ° Ratios of areas are preserved

1 2 1 2

1 1 1 x a a a u y b b b v             =                  

slide-27
SLIDE 27

Solution to Affine Warping

1 2 1 2

1 1 1 x a a a u y b b b v             =                  

slide-28
SLIDE 28

“Triangle-wise” parametric image warping

  • For each transformed image frame

° Define a mesh of triangles ° Find a affine transform from each triangle’s vertices, apply it to other points inside the triangle  Have to solve affine transforms at every frame

M1 M2

slide-29
SLIDE 29

Content

  • Introduction
  • Parametric warping
  • Barycentric coordinates
  • Interpolation
  • MP6
slide-30
SLIDE 30

Affine warping for triangles

slide-31
SLIDE 31

Barycentric Coordinates

slide-32
SLIDE 32

Barycentric Coordinates

Fact

slide-33
SLIDE 33

Content

  • Introduction
  • Parametric warping
  • Barycentric

coordinates

  • Interpolation
  • MP6
slide-34
SLIDE 34

Image Warping Implementation I

slide-35
SLIDE 35

Forward Mapping

slide-36
SLIDE 36

Forward Mapping

slide-37
SLIDE 37

Forward Mapping

slide-38
SLIDE 38

Image Warping Implementation II

slide-39
SLIDE 39

Reverse Mapping

slide-40
SLIDE 40

Resampling

Evaluate source image at arbitrary (u, v)

° (u, v) does not usually have integer coordinates

Some kinds of resampling

° Nearest neighbor ° Bilinear interpolation ° Gaussian filter

Source Image Destination Image

slide-41
SLIDE 41

Nearest neighbor

Take value at closest pixel

int iu = trunc(u + 0.5); int iv = trunc(v + 0.5); dst(x, y) = src(iu, iv);

Simple, but causes aliasing

slide-42
SLIDE 42

Bilinear interpolation

Bilinearly interpolate four surrounding pixels

a = linear interpolation of src(u1, v1) and src(u2, v1) b = linear interpolation of src(u1, v2) and src(u2, v2) dst(x, y) = linear interpolation of ‘a’ and ‘b’ a b

(u1,v1) (u2,v1) (u2,v2) (u1,v2) (x,y)

slide-43
SLIDE 43

Gaussian Filter

Convolve with Gaussian filter

Width of Gaussian kernel affects bluriness

slide-44
SLIDE 44

Image Warping Implementation II – with resampling

slide-45
SLIDE 45

Image Warping Implementation II – with Gaussian resampling

slide-46
SLIDE 46

Content

  • Introduction
  • Parametric warping
  • Barycentric

coordinates

  • Interpolation
  • MP6
slide-47
SLIDE 47

Warping in MP6

  • Warping

° For each triangle find the affine transform ° Apply it to the points inside ° Assign image value to the triangle points

  • Suggestions

° Barycentric coordinate ° Reverse mapping

slide-48
SLIDE 48

Preview of MP6