Professional Documents
Culture Documents
Lecture 22
Lecture 22
Lecture 22
Recap
Mesh Warping
Mappings between Quadrilaterals
Summary
Recap
x11
xb xd
1 x
x10
x01
v xa
u
xc
x00
u 1
Recap
bilinear mappings
I solution:
bilinear mappings
I solution:
I in matrix form:
uv
x a b c d u
=
y e f g h v
1
Recap
bilinear mappings
I for the coefficients a, b, . . . , h we have
projective mappings
I two operations
Mesh Warping
projective mappings
I two operations
I first, a spatial transformation
0
a b c u u
d e f v = v 0
g h 1 1 w0
Mesh Warping
projective mappings
I two operations
I first, a spatial transformation
0
a b c u u
d e f v = v 0
g h 1 1 w0
I second, a projection
u0 au + bv + c
x= 0
=
w gu + hv + 1
v0 du + ev + f
y= 0 =
w gu + hv + 1
Mesh Warping
projective mappings
I w.l.o.g., entry i in the transformation matrix can be set to 1
Mesh Warping
projective mappings
I w.l.o.g., entry i in the transformation matrix can be set to 1
projective mappings
I w.l.o.g., entry i in the transformation matrix can be set to 1
xi = (xi , yi ) ⇔ ui = (ui , vi )
in two images, one can determine the
perspective transformation T between
the images
Mesh Warping
xi = (xi , yi ) ⇔ ui = (ui , vi )
in two images, one can determine the
perspective transformation T between
the images
I simply consider
aui + bvi + c
xi =
gui + hvi + 1
dui + evi + f
yi =
gui + hvi + 1
⇒xi = ui a + vi b + c − ui xi g − vi yi h
yi = ui d + vi e + f − ui xi g − vi yi h
Mesh Warping
note:
image mosaics
I if the perspective mapping between a series of image was
known, the images could be rendered into a single mosaic
image
Mesh Warping
image mosaics
I if the perspective mapping between a series of image was
known, the images could be rendered into a single mosaic
image
I in its most simple form, this requires that the series of
images had been captured by a rotating camera or by
a camera moving along a linear trajectory
Mesh Warping
image mosaics
I if the perspective mapping between a series of image was
known, the images could be rendered into a single mosaic
image
I in its most simple form, this requires that the series of
images had been captured by a rotating camera or by
a camera moving along a linear trajectory
I mosaics could also be computed from image series that
violate this simple prerequisite, however, in these cases,
simple perspective mappings do not allow for an accurate
integration of the individual images
Mesh Warping
image mosaics
Mesh Warping
image mosaics
Mesh Warping
image mosaics
Scanline Mesh Warping
x = T(u)
i.e. with
x Tx (u, v)
=
y Ty (u, v)
∆ = Ty (u(x, v), v)
Scanline Mesh Warping
x11
xb xd
1 x
x10
x01
v xa
u
xc
x00
u 1
Scanline Mesh Warping
x = v(xb − xa ) + xa
Scanline Mesh Warping
x = v(xb − xa ) + xa
i.e.
x = u(xd − xc ) + xc
Scanline Mesh Warping
i.e.
x = u(xd − xc ) + xc
where
and
mesh warping
I the separability of bilinear maps provides a simple and
efficient way of warping an image locally
Scanline Mesh Warping
mesh warping
mesh warping
I a regular mesh or lattice is defined over an image
Scanline Mesh Warping
mesh warping
I a regular mesh or lattice is defined over an image
I a slightly different quadrilateral structure results from
small displacements of the vertices of the mesh
Scanline Mesh Warping
mesh warping
I a regular mesh or lattice is defined over an image
I a slightly different quadrilateral structure results from
small displacements of the vertices of the mesh
I when shifting vertices of the mesh, we must ensure that
mesh warping
approach
### step 1: distortion along the x direction
for v in range(rmax):
for k in range(numGridPointsX):
for l in range(numGridPointsY):
srcColX[l] = srcGridX[l,k]
srcColY[l] = srcGridY[l,k]
dstColX[l] = dstGridX[l,k]
dstColY[l] = dstGridY[l,k]
srcIntersectX[k] = interpol(srcColY, srcColX, numGridPointsY, v)
dstIntersectX[k] = interpol(dstColY, dstColX, numGridPointsY, v)
for x in range(cmax):
u = interpol(dstIntersectX, srcIntersectX, numGridPointsX, x)
gDx[v*cmax,x] = resample(gOrig, u, v)
for y in range(rmax):
v = interpol(dstIntersectY, srcIntersectY, numGridPointsY, y)
gDxDy[y*cmax,x] = resample(gDx, x, v)
Scanline Mesh Warping
mesh warping
I once again
mesh warping
I explanation
I in the first step, an intermediate image gDx is computed
that shows a warped version of the original image where
the warp was applied along the x direction
I to this end, the script iterates over all rows v of the image;
in each iteration, the vertical lines (i.e. the columns) of the
original mesh are stored in srcCol and the vertical lines of
the warped mesh are stored in dstCol; subsequently, the
points of intersection of the vertical mesh lines with the
current row of the image are computed; the x-coordinates of
these points of intersection with image row v are stored in
the arrays srcIntersectX and dstIntersectX,
respectively
Scanline Mesh Warping
mesh warping
I explanation (cont.)
I then, the script iterates over all columns x of the current
row v and, by means of interpolation between the recently
collected points of intersection of the row with the lines of
the original mesh and the lines of the distorted mesh, it is
being determined, which column u in the original image
gOrig corresponds to the current column x
I finally, the color value at coordinate (u,v) is read from
gOrig and stored at coordinate (x,v) in gDx
Scanline Mesh Warping
mesh warping
I explanation (cont.)
I in a second step, the intermediate result gDx is turned into
the desired warped image gDxDy
I this happens in analogy to the first step but the roles of
rows and columns are exchanged
Scanline Mesh Warping
caricatures
I using the technique to create caricatures is straightforward
Scanline Mesh Warping
mesh morphing
I the famous effect of morphing, too, has its roots in mesh
warping
Scanline Mesh Warping
algorithm
define a grid GS to overlay over the source image IS
define a grid GD to overlay over the destination image ID
(corresponding grid points should ideally come to lie over
corresponding image contents)
mesh morphing
Scanline Mesh Warping
mesh morphing
I the second and fourth rows in the figure show the warped
images ISt and IDt , respectively
I the middle row in the figure shows the images IS , It (where
t ∈ {1, 2, 3}) and ID
Scanline Mesh Warping
mesh morphing
I the second and fourth rows in the figure show the warped
images ISt and IDt , respectively
I the middle row in the figure shows the images IS , It (where
t ∈ {1, 2, 3}) and ID
note: