Beruflich Dokumente
Kultur Dokumente
Warping, Registration,
Morphing
Yao Wang
Polytechnic University, Brooklyn, NY 11201
With contribution from Zhu Liu, Onur Guleryuz, and
Partly based on
A K.
A.
K Jain,
Jain Fundamentals of Digital Image Processing
Lecture Outline
Introduction
Image deformation model
Image warping
Image registration
Image morphing
Geometric Transformation
Geometric Transformation
x x(u, v)
, or
y
(
u
,
v
)
Inverse mapping:
u u ( x, y )
, or u u (x)
v
(
x
,
y
)
x x(u)
f
(
u
,
v
)
g
(
x
(
u
,
v
),
y
(
u
,
v
))
f (u) g ( x(u))
Geometric Transformation
v
Forward
x(u,v),
( ) y(u,v)
( )
(u, v)
v
u
Geometric Transformation
x
u
Inverse
u(x,y), v(x,y)
(x, y)
Translation
Translation is defined by the following
v
mapping functions:
x u tx
y v ty
and
u x tx
v y ty
In matrix notation
x u t, u x t
where
(tx,ty)
t x
x
u
x , u , t .
y
v
t y
Geometric Transformation
Scaling
Scaling is defined by
x sxu
and
y
s
v
y
u x / s x
v y / s y
v
sx=2,sy=1/2
Matrix notation
x Su, u S 1x
where
sx
S
0
0
s y
If sx < 1 and
d sy < 1,
1 thi
this represents
t a minification
i ifi ti
or shrinking, if sx >1 and sy > 1, it represents a
magnification or zoom.
zoom
Geometric Transformation
Rotation
Rotation by an angle of is defined by
x u cos v sin
i
y u sin v cos
and
i
u x cos y sin
v x sin y cos
In matrix format
v
=/4
x Ru, u R T x
where
cos
R
sin
sin
cos
(x,y)
(u,v)
By Onur Guleyuz
Geometric Transformation
Geometric Transformation
A geometric transformation refers to a
combination of translation,
translation scaling,
scaling and
rotation, with a general form of
x RS(u t ) Au b,
u A 1 (x b) A 1x c,
with A RS, b RSt, c t.
Geometric Transformation
10
Affine Mapping
All possible geometric transformations are special cases
pp g
of the Affine Mapping:
x a0 a1u a2v
or x Au b
b
u
b
v
0
1
2
a a
A 1 2 ,
b1 b2
a
b 0
b0
Geometric Transformation
11
v 3
y
2
1
2
x
12
v 3
y
2
1
2
Geometric Transformation
13
Matlab Functions
14
G = MAKETFORM('affine',T) builds a TFORM struct G for an Ndimensional affine transformation. T defines a forward
transformation such that TFORMFWD(U,T),
TFORMFWD(U T) where U is a 1
1-by-N
by N
vector, returns a 1-by-N vector X such that X = U * T(1:N,1:N) +
T(N+1,1:N).T has both forward and inverse transformations. N=2 for
2D image transformation
In MATLAB notation
a1
T a2
a0
Geometric
Geometric
Transformation
Transformation
b1
b2
b0
0
T
A
0 T
EL512EL512
ImageImage
Processing
Processing
15
15
Geometric Transformation
16
tform = maketform(
maketform('affine'
affine ,[1
[1 0 0; .5
5 1 0; 0 0 1]);
In MATLAB, affine transform is defined by:
[a1,b1,0;a2,b2,0;a0,b0,1]
With notation
t ti usedd in
i this
thi lecture
l t
t
note
1 0.5
A
,
0
1
0
b
0
Note in this example, first coordinate indicates horizontal position, second coordinate indicate vertic
Geometric Transformation
17
Bilinear Mapping
x a0 a1u a2v a3uv
Geometric Transformation
18
3
v 3
y
2
2
Geometric Transformation
1 u
1
EL512 Image Processing
x
19
Non-chirping models
(Original)
(Affine)
Chirping models
(Bilinear)
(Projective)
(Relativeprojective)
(Pseudoperspective)
(Biquadratic)
20
Polynomial Warping
The polynomial warping includes all deformations that
can be modeled by polynomial transformations:
x a0 a1u a2 v a3uv a4u 2 a5v 2
b5v 2
y
b
b
u
b
v
b
uv
b
u
0
1
2
3
4
Geometric Transformation
21
Geometric Transformation
22
P1
P P3
P2
P4
P will be interpolated
from P1, P2, P3, and P4
Geometric Transformation
23
Interpolation Method
Nearest neighbor:
Round (u
(u,v)
v) to the nearest integer samples
Bilinear interpolation:
find four integer samples nearest to (u,v),
apply bilinear interpolation
O
Other
h higher
hi h order
d iinterpolation
l i methods
h d
can also be used
Requiring more than 4 nearest integer
samples!
Geometric Transformation
24
Geometric Transformation
25
Geometric Transformation
26
Geometric Transformation
27
Geometric Transformation
28
tform = maketform(
maketform('affine'
affine ,[1
[1 0 0; .5
5 1 0; 0 0 1]);
In MATLAB, affine transform is defined by:
[a1,b1,0;a2,b2,0;a0,b0,1]
With notation
t ti usedd in
i this
thi lecture
l t
t
note
1 0.5
A
,
0
1
0
b
0
29
Two-Pass Mapping
The idea is to transform each row of f(u, v) first, to obtain
an intermediate image, f(x,y), and then each column of
this intermediate image is transformed to obtain the final
image g(x, y).
(u,v)
f(u,v)
xx=u
=u, y=y(u
y =y(u,v)
v)
i u
x cos sin
Ex: rotation
y sin cos v
Step 1: Fixed each row x=u, find y=usin+vcos
f( y)=f(u,v)
f(x,
) f( )
Step2: Fix each column y=y find x=ucos-vsin
y 'u sin y ' x' sin
cos
cos
u x'
Geometric Transformation
x x' cos
(u,y(u,v))
f(x,y)
x=x(x,y)=x(u,v)
y=y
(x(u,v),y(u,v))
30
WAVE2
wave1:x(u,v)=u+20sin(2v/128);y(u,v)=v;
wave1:x(u,v)
u 20sin(2v/128);y(u,v) v;
wave2:x(u,v)=u+20sin(2u/30);y(u,v)=v.
By Onur Guleyuz
Geometric Transformation
31
SWIRL
WARP
SWIRL
Geometric Transformation
32
Image Registration
Suppose we are given two images taken at
different times of the same object. To observe
the changes between these two images, we
need to make sure that they are aligned properly.
To obtain this goal, we need to find the correct
mapping function between the two. The
determination of the mapping functions between
two images is known as the registration problem.
Once the mapping function is determined
determined, the
alignment step can be accomplished using the
warping methods.
Geometric Transformation
33
y (ui , vi ) b0 b1ui b2 vi yi ,
34
1 u K
v1
v2
vK
a0
b0
x1
y1
a
b
x
y
1
1
2
, b
, x , y 2
,a
a
b
x
K
yK
N 1
N 1
a A 1x, b A 1y
If K > N,
N then
th we can use a least
l
t square solution
l ti
a ( A T A) 1 A T x, b ( A T A) 1 A T y
If K < N,
N or A is singular
singular, then more corresponding feature points
must be identified.
Geometric Transformation
35
Examples
If we want to use an affine mapping to
register to images
images, we need to find 3 or
more pairs of corresponding points
If we have only 3 pairs
pairs, we can solve the
mapping parameters exactly as before
If we have more than 3 pairs, these pairs
may not all be related by an affine
mapping. We find the least squares fit by
solving an over-determined system of
equations
Geometric Transformation
36
Example
Geometric Transformation
37
Geometric Transformation
38
Geometric Transformation
39
Ry
dm
Bm
Best match
Search region
Bm
Current block
40
MATLAB Example
Geometric Transformation
41
Image Morphing
Image morphing has been widely used in
movies and commercials to create special visual
effects. For example, changing a beauty
gradually into a monster.
The fundamental techniques behind image
morphing is image warping.
Let the original image be f(u) and the final image
be g(x). In image warping, we create g(x) from
f( ) b
f(u)
by changing
h
i itits shape.
h
IIn iimage morphing,
hi
we use a combination of both f(u) and g(x) to
create a series of intermediate images
images.
Geometric Transformation
42
Mesh
based
George Wolberg,
Wolberg Recent
Recent Advances in Image Morphing
Morphing ,
Computer Graphics Intl. '96, Pohang, Korea, June 1996.
Geometric Transformation
43
Geometric Transformation
44
Geometric Transformation
45
Demo
Show work by senior students
Geometric Transformation
46
Homework
You are given two pictures of the same scene, taken at different
times. In order to align the two pictures, you need to find a
mapping function between the two pictures based on some
common feature
f t
points.
i t Suppose
S
you were able
bl to
t extract
t tN
(N>=3) feature points in both images that correspond to the same
set of object features, with image coordinates given as (u_k,v_k)
and (x_k,y_k),k=1,2,,N. Also, suppose you want to use an affine
mapping
i tto approximate
i t th
the actual
t l unknown
k
mapping
i ffunction.
ti
How would you determine the affine mapping parameters?
Suppose you want make a panoramic picture of a wide landscape
p
y captured
p
p
pictures with a certain overlap.
p
out of two separately
Propose an algorithm for stitching up the two images to make a
panorama. (list the steps involved).
Computer assignment: Write a matlab program that implements
rotation of an image by a certain angle, and apply it on a selected
image. The rotation center should be the image center. Please
note that you should not use the imrotate() or imtransform()
function in MATLAB. You should write your own program, which
can call interp2().
interp2() .
Geometric Transformation
47
Reading
Prof. Yao Wangs Lecture Notes, Chapter
10.
10
R. Gonzalez, Digital Image Processing,
Section 5
5.11
11
George Wolberg, Digital Image Warping,
Wiley-IEEE Computer Society Press, 1990
Geometric Transformation
48