Page 166 -
P. 166
3.6 Geometric transformations 145
procedure forwardWarp(f, h, out g):
For every pixel x in f(x)
1. Compute the destination location x = h(x).
2. Copy the pixel f(x) to g(x ).
Algorithm 3.1 Forward warping algorithm for transforming an image f(x) into an image g(x ) through the
parametric transform x = h(x).
x’=h(x) x’=h(x)
x x’ x x’
f(x) g(x’) f(x) g(x’)
(a) (b)
Figure 3.46 Forward warping algorithm: (a) a pixel f(x) is copied to its corresponding location x = h(x) in
image g(x ); (b) detail of the source and destination pixel locations.
3.6.1 Parametric transformations
Parametric transformations apply a global deformation to an image, where the behavior of the
transformation is controlled by a small number of parameters. Figure 3.45 shows a few ex-
amples of such transformations, which are based on the 2D geometric transformations shown
in Figure 2.4. The formulas for these transformations were originally given in Table 2.1 and
are reproduced here in Table 3.5 for ease of reference.
In general, given a transformation specified by a formula x = h(x) and a source image
f(x), how do we compute the values of the pixels in the new image g(x), as given in (3.88)?
Think about this for a minute before proceeding and see if you can figure it out.
If you are like most people, you will come up with an algorithm that looks something like
Algorithm 3.1. This process is called forward warping or forward mapping and is shown in
Figure 3.46a. Can you think of any problems with this approach?
In fact, this approach suffers from several limitations. The process of copying a pixel
f(x) to a location x in g is not well defined when x has a non-integer value. What do we
do in such a case? What would you do?
You can round the value of x to the nearest integer coordinate and copy the pixel there,
but the resulting image has severe aliasing and pixels that jump around a lot when animating
the transformation. You can also “distribute” the value among its four nearest neighbors in
a weighted (bilinear) fashion, keeping track of the per-pixel weights and normalizing at the
end. This technique is called splatting and is sometimes used for volume rendering in the
graphics community (Levoy and Whitted 1985; Levoy 1988; Westover 1989; Rusinkiewicz
and Levoy 2000). Unfortunately, it suffers from both moderate amounts of aliasing and a
fair amount of blur (loss of high-resolution detail).