
Image Geometry 145
(478, 323)
(129, 283)(129, −283)
(478, −323)
0
FIGURE 6.27: The trapezoid around the building
However, this involves a division, which is in general a slow operation. To rewrite as a
multiplication, we would use replace pixel at (x, y) in the new image would take the place
of a pixel at place
(x, sq(x, y − 352) + 352)
where sq (x ) (“sq” stands for “squash”) is a linear function for which
sq(0) = a/b
sq(r) = 1.
This means that
sq(x) =
b −a
br
(x) +
a
b
.
Here’s how this can be implemented in MATLAB or Octave, assuming that the image has
been read as im:
MATLAB/Octave
>> [r,c] = size(im);
>> z = zeros(r,c);
>> x1 = 129; y1=283; x2=478; y2=323;
>> a