geometric transformations and image warping chapter 2.6gerig/cs6640-f2010/geometric_trans_gg.pdf ·...

104
Univ of Utah, CS6640 2010 1 Geometric Transformations and Image Warping Chapter 2.6.5 Ross Whitaker (modified by Guido Gerig) SCI Institute, School of Computing University of Utah

Upload: others

Post on 17-Jun-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 1

Geometric Transformations and Image Warping

Chapter 2.6.5Ross Whitaker

(modified by Guido Gerig)SCI Institute, School of Computing

University of Utah

Page 2: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 2

Geometric Transformations

• Greyscale transformations -> operate on range/output

• Geometric transformations -> operate on image domain– Coordinate transformations– Moving image content from one place to another

• Two parts:1. Define transformation2. Resample greyscale image in new coordinates

Page 3: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 3

Geom Trans: Distortion From Optics

Barrel Distortion Pincushion Distortion

Page 4: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

ComputerVision

Radial distortion example

Page 5: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 5

Geom Trans: Distortion From Optics

Page 6: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 6

Geom. Trans.: Brain Template/Atlas

Page 7: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 7

Geom. Trans.: Mosaicing of Series of Images

Page 8: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 8

Domain Mappings Formulation

New image from old one

Coordinate transformationTwo parts – vector valued

g is the same (intensity) image as f, but sampled on these new coordinates

Page 9: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 9

Domain Mappings Formulation

g is the same (intensity) image as f, but sampled on these new coordinates

(E. H. W. Meijering)

Page 10: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 10

Domain Mappings Formulation

Vector notation is convenient. Bar used some times, depends on context.

T may or may not have an inverse. If not, it means that information was lost.

Page 11: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 11

Domain Mappings

f g

f g

Page 12: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 12

No Inverse?

f g

f gNot “one to one”

Not “onto” -doesn’t cover f

Page 13: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Example

Univ of Utah, CS6640 2010 13

Page 14: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

14

Transformation Examples

• Linear

• Rotation, Translation, Scaling?

Page 15: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

10/5/04 © University of Wisconsin, CS559 Fall 2004

2D Rotation

• Rotate counter-clockwise about the origin by an angle θ

+

−=

′′

00

cossinsincos

yx

yx

θθθθ

x

y

x

y

θ

Page 16: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

10/5/04 © University of Wisconsin, CS559 Fall 2004

Rotating About An Arbitrary Point

• What happens when you apply a rotation transformation to an object that is not at the origin?

x

y

?

Page 17: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

10/5/04 © University of Wisconsin, CS559 Fall 2004

Rotating About An Arbitrary Point

• What happens when you apply a rotation transformation to an object that is not at the origin?– It translates as well

x

y

x

Page 18: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

10/5/04 © University of Wisconsin, CS559 Fall 2004

Now: First Rotate, then Translate

• Rotation followed by translation is not the same as translation followed by rotation:

• T(R(object)) ≠ R(T(object))

x

θ

x

θ

Page 19: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Guido Gerig COMP 256 / Fall 2001 19

Series of Transformations

2D Object: Translate, scale, rotate, translate again

Problem: Rotation, scaling, shearing are multiplicative transforms, but translation is additive.

Page 20: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Excellent Materials for self study

10/5/04 © University of Wisconsin, CS559 Fall 2004

http://groups.csail.mit.edu/graphics/classes/6.837/F01/Lecture07/Slide01.html

Page 21: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

10/5/04 © University of Wisconsin, CS559 Fall 2004

Homogeneous Coordinates

• Use three numbers to represent a point• (x,y)=(wx,wy,w) for any constant w≠0

– Typically, (x,y) becomes (x,y,1)– To go backwards, divide by w

• Translation can now be done with matrix multiplication!

=

′′

11001yx

baabaa

yx

yyyyx

xxyxx

Page 22: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

10/5/04 © University of Wisconsin, CS559 Fall 2004

Basic Transformations

• Translation: Rotation:

• Scaling:

1001001

y

x

bb

1000000

y

x

ss

1000cossin0sincos

θθθθ

Page 23: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 23

Transformation Examples

• Linear

• Homogeneous coordinates

Page 24: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 24

Special Cases of Linear

• Translation

• Rotation

• Rigid = rotation + translation

• Scaling

– Include forward and backward rotation for arbitary axis

• Skew

• Reflection

p, q < 1 : expand

Page 25: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Linear Transformations

Univ of Utah, CS6640 2010 25

Page 26: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Cascading of Transformations

Univ of Utah, CS6640 2010 26

Demo:http://groups.csail.mit.edu/graphics/classes/6.837/F01/Lecture07/Slide09.html

Page 27: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Guido Gerig COMP 256 / Fall 2001 27

Homogeneous Coordinates: A general view

• Acknowledgement: Greg Welch, Gary Bishop, Siggraph 2001 Course Notes (Tracking).

Page 28: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Guido Gerig COMP 256 / Fall 2001 28

Series of Transformations

2D Object: Translate, scale, rotate, translate again

Problem: Rotation, scaling, shearing are multiplicative transforms, but translation is additive.

Page 29: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Guido Gerig COMP 256 / Fall 2001 29

Solution: Homogeneous Coordinates

• In 2D: add a third coordinate, w

• Point [x,y]T expanded to [x,y,w]T

• Scaling: force w to 1 by [x,y,w]T/w → [x/w,y/w,1]T

Page 30: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Guido Gerig COMP 256 / Fall 2001 30

Resulting Transformations

new:

before:

Page 31: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 31

Linear Transformations

• Also called “affine”– 6 parameters

• Rigid -> 3 parameters• Invertability

– Invert matrix• What does it mean if A is not invertible?

Page 32: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Affine: General Linear Transformation

Univ of Utah, CS6640 2010 32

6 parameters for Trans (2), Scal (2), Rot (1), Shear X and Shear Y → 7 Parameters ?????

Page 33: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Affine: General Linear Transformation

Univ of Utah, CS6640 2010 33

Rot 90deg Shear X Rot -90deg

Shear Y

6 parameters for Trans (2), Scal (2), Rot (1), Shear X and Shear Y → 7 Parameters ?????

Shear Y can be formulated as Shear X applied to rotated image -> There is only one Shear parameter

1)

2)

Page 34: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Implementation

Two major procedures:1. Definition or estimation of

transformation type and parameters2. Application of transformation: Actual

transformation of image

Univ of Utah, CS6640 2010 34

Page 35: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 35

Implementation – Two Approaches to Apply Transf.

1. Pixel filling – forward mapping g to f• T() takes you from coords in g() to coords in f()• Need random access to pixels in f()• Sample grid for g(), interpolate f() as needed

f g

Interpolate from nearby grid points

Page 36: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 36

Interpolation: Bilinear

• Successive application of linear interpolation along each axis

Source: WIkipedia

Page 37: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 37

Bilinear Interpolation

• Not linear in x, y

Page 38: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 38

Bilinear Interpolation

• Convenient form– Normalize to unit grid [0,1]x[0,1]

Page 39: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 39

Implementation – Two Approaches

2. Splatting – backward mapping f to g• T-1() takes you from coords in f() to coords in g()• You have f() on grid, but you need g() on grid• Push grid samples onto g() grid and do

interpolation from unorganized data (kernel)

f g

Nearby points are not organized –”scattered”

?

Page 40: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 40

Scattered Data Interpolation With KernelsShepard’s method

• Define kernel– Falls off with distance, radially symmetric

g

?

Kernel examples

Grid coordinates in fRequired grid coordinates in g

Transformed coord. from f

Page 41: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 41

Shepard’s Method Implementation

• If points are dense enough– Truncate kernel– For each point in f()

• Form a small box around it in g() – beyond which truncate

• Put weights and data onto grid in g()

– Divide total data by total weights: B/A g

Data and weights accumulated here

Page 42: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

ESTIMATION OF TRANSFORMATIONS

Univ of Utah, CS6640 2010 42

Page 43: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 43

Determine Transformations• All polynomials of (x,y)• Any vector valued function with 2 inputs• How to construct transformations?

– Define form or class of a transformation– Choose parameters within that class

• Rigid - 3 parameters (T, R)• Affine - 6 parameters

Page 44: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 44

Correspondences

• Also called “landmarks” or “fiducials”

Page 45: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Question: How many landmarks for affine T?

• Estimation of 6 parameters → 3 corresponding point pairs with (x,y) coordinates

Univ of Utah, CS6640 2010 45

Page 46: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 46

Transformations/Control PointsStrategy

1. Define a functional representation for T with k parameters (β)

2. Define (pick) N correspondences3. Find β so that

4. If overconstrained (K < 2N) then solve

Page 47: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Example Affine Transformation: 3 Corresponding Landmarks

Univ of Utah, CS6640 2010 47

Page 48: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 48

Example: QuadraticTransformation

Denote

Correspondences must match

Note: these equations are linear in the unkowns

Page 49: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 49

Write As Linear System

A – matrix that depends on the (unprimed) correspondences and the transformation

x – unknown parameters of the transformation

b – the primed correspondences

Page 50: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 50

Linear Algebra Background

Simple case: A is square (M=N) and invertable (det[A] not zero)

(Numerics: Don’t find A inverse. Use Gaussian elimination or some kind of decomposition of A.)

Page 51: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 51

Linear Systems – Other Cases

• (M<N) or (M = N and the equations are degenerate or singular): – System is underconstrained – lots of

solutions• Approach

– Impose some extra criterion on the solution– Find the one solution that optimizes that

criterion– Regularizing the problem

Page 52: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 52

Linear Systems – Other Cases

• M > N (e.g. more points than parameters): – System is overconstrained– No solution

• Approach– Find solution that is best compromise – Minimize squared error (least squares)

Page 53: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 53

Solving Least Squares Systems

• Pseudoinverse (normal equations)

– Issue: often not well conditioned (nearly singular)

• Alternative: singular value decomposition SVD

Page 54: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 54

Singular Value Decomposition

Invert matrix A with SVD

Page 55: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 55

SVD for Singular Systems

• If a system is singular, some of the w’s will be zero

• Properties:– Underconstrained: solution with shortest

overall length– Overconstrained: least squares solution

Page 56: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

SPECIFYING “WARPS” VIA SPARSE SET OF LANDMARKS

Univ of Utah, CS6640 2010 56

Page 57: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 57

Specifying Warps – Another Strategy

• Let the # DOFs in the warp equal the # of control points (x1/2)– Interpolate with some grid-based interpolation

• E.g. binlinear, splines

Page 58: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 58

Landmarks Not On Grid

• Landmark positions driven by application• Interpolate transformation at unorganized

correspondences– Scattered data interpolation

• How do we do scattered data interpolation?– Idea: use kernels!

• Radial basis functions– Radially symmetric functions of distance to

landmark

Page 59: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Concept

Univ of Utah, CS6640 2010 59

Page 60: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Concept

Univ of Utah, CS6640 2010 60

Warping a Neuro-Anatomy Atlas on 3D MRI Data with Radial Basis Functions H.E. Bennink, J.M. Korbeeck, B.J. Janssen, B.M. ter Haar Romeny

Page 61: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Concept

Univ of Utah, CS6640 2010 61

Page 62: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 62

• Represent T as weighted sum of basis functions

• Need interpolation for vector-valued function, T:

RBFs – Formulation

Sum of radial basis functionsBasis functions centered at positions of data

T

Page 63: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Choices for ϕ

• Gaussian: g(t) = exp(-0.5(t2/σ2)• Multiquadratics: g(t) = 1/Sqrt(t2+c2),

where c is least distance to surrounding points

Univ of Utah, CS6640 2010 63

Page 64: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 64

Solve For k’s With Landmarks as Constraints

• Find the k’s so that T(x) fits at data points

Page 65: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 65

Issue: RBFs Do Not Easily Model Linear Trends

f(x)

x

f1

f2

f3

x1 x2 x3

Page 66: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 66

• Represent T as weighted sum of basis functions and linear part

• Need interpolation for vector-valued function, T:

RBFs – Formulation w/Linear Term

Sum of radial basis functionsLinear part of transformation Basis functions centered

at positions of data

T

Page 67: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 67

RBFs – Linear System

Page 68: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 68

RBFs – Solution Strategy• Find the k’s and p’s so that T() fits at data points

– The k’s can have no linear trend (force it into the p’s)

• Constraints -> linear systemCorrespondences must match

Keep linear part separate from deformation

Page 69: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 69

RBF Warp – Example

Page 70: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 70

What Kernel Should We Use

• Gaussian– Variance is free parameter – controls

smoothness of warp

σ = 2.5 σ = 2.0 σ = 1.5

From: Arad et al. 1994

Page 71: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 71

RBFs – Aligning Faces

Mona Lisa – Target Venus – Source Venus – Warped

Page 72: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Symmetry?

Univ of Utah, CS6640 2010 72

Image-based Talking Heads using Radial Basis Functions James D. Edge and Steve Maddock

Page 73: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Application

• Modeling of lip motion in speech with few landmarks.

• Synthesis via motion of landmarks.

Univ of Utah, CS6640 2010 73

Page 74: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 74

RBFs – Special Case: Thin Plate Splines

• A special class of kernels

• Minimizes the distortion function (bending energy)

– No scale parameter. Gives smoothest results– Bookstein, 1989

Page 75: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 75

Application: Image Morphing

• Combine shape and intensity with time parameter t– Just blending with amounts t produces “fade”

– Use control points with interpolation in t

– Use c1, c(t) landmarks to define T1, and c2,c(t) landmarks to define T2

Page 76: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 76

Image Morphing

• Create from blend of two warped images

T2T1

I1 It I2

Page 77: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 77

Image Morphing

Page 78: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 78

Application: Image Templates/Atlases

• Build image templates that capture statistics of class of images– Accounts for shape and intensity– Mean and variability

• Purpose– Establish common coordinate system (for

comparisons)– Understand how a particular case compares to the

general population

Page 79: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 79

Templates – Formulation

• N landmarks over M different subjects/samples

Images

Correspondences

Mean of correspondences (template)

Transformations from mean to subjects Templated image

Page 80: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 80

Cars

Page 81: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 81

Car Landmarks and Warp

Page 82: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 82

Car Landmarks and Warp

Page 83: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 83

Car Mean

Page 84: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 84

Cars

Page 85: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 85

Cats

Page 86: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 86

Brains

Page 87: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 87

Brain Template

Page 88: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

APPLICATIONS

Univ of Utah, CS6640 2010 88

Page 89: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 89

Warping Application: Lens Distortion

• Radial transformation – lenses are generally circularly symmetric– Optical center is known– Model of transformation:

Page 90: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 90

Correspondences• Take picture of known grid – crossings

• Measure set of landmark pairs → Estimate transformation, correct images

Page 91: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 91

Image Mosaicing

• Piecing together images to create a larger mosaic

• Doing it the old fashioned way– Paper pictures and tape– Things don’t line up– Translation is not enough

• Need some kind of warp• Constraints

– Warping/matching two regions of two different images only works when…

Page 92: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Applications

Univ of Utah, CS6640 2010 92

Page 93: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Microscopy (Morane Eye Inst, UofU, T. Tasdizen et al.)

Univ of Utah, CS6640 2010 93

Page 94: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 94

Page 95: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 95

Special Cases

• Nothing new in the scene is uncovered in one view vs another– No ray from the camera gets behind another

1) Pure rotations–arbitrary scene 2) Arbitrary views of planar surfaces

Page 96: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 96

3D Perspective and Projection

• Camera model

z

xy

f

Image coordinates

Page 97: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 97

Perspective Projection Properties

• Lines to lines (linear)

• Conic sections to conic sections

• Convex shapes to convex shapes

• Foreshortening

Page 98: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 98

Image Homologies

• Images taken under cases 1,2 are perspectively equivalent to within a linear transformation– Projective relationships – equivalence is

Page 99: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 99

Transforming Images To Make Mosaics

Linear transformation with matrix P

Perspective equivalence Multiply by denominator and reorganize terms

Linear system, solve for P

Page 100: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 100

Image Mosaicing

Page 101: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 101

4 Correspondences

Page 102: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 102

5 Correspondences

Page 103: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 103

6 Correspondences

Page 104: Geometric Transformations and Image Warping Chapter 2.6gerig/CS6640-F2010/geometric_trans_GG.pdf · 2010-10-06 · Univ of Uah, CS6640 2010 1 Geometric Transformations and Image Warping

Univ of Utah, CS6640 2010 104

Mosaicing Issues

• Need a canvas (adjust coordinates/origin)

• Blending at edges of images (avoid sharp transitions)

• Adjusting brightnesses• Cascading transformations