<< Chapter < Page | Chapter >> Page > |
We now turn our attention to operating on the point matrix $G$ to produce the desired transformations. We will consider
We call $A$ a matrix operator because it “operates” on $G$ through matrix multiplication. In contrast, translation must be done by matrix addition.
In a later section you will see that it is advantageous to perform all operations by matrix operators and that we can modify our image representation to allow translation to be done with a matrix operator like rotation andscaling. We will call the modified representation homogeneous coordinates .
Rotation. We saw in the chapter on linear algebra that the matrix that rotates points by an angle $\theta $ is
When applied to the point matrix G , this matrix operator rotates each point by the angle θ , regardless of the number of points.
We can use the rotation matrix to do the single point rotation of the example from "Vector Graphics: Introduction" . We have a point matrix consisting of only the point $(3,1)$ :
The necessary transformation matrix is $R\left(\theta \right)$ with $\theta =\frac{\pi}{6}$ Then the rotated point is given by
Scaling. An object can be enlarged or reduced in each dimension inde- pendently. The matrix operator that scales an image by a factor of ${s}_{x}$ along the x-axis and ${s}_{y}$ along the y-axis is
Most often we take ${s}_{x}={s}_{y}$ to scale an image by the same amount in both dimensions.
Translation. An object can be moved by adding a constant vector b to every point in the object. For example, $b=20-5$ will move an object 20 units to the right and 5 units down. We can write this in terms of the point matrix as
where 1 (read “the one-vector”) is a vector of n l's:
In MATLAB, 1 may be obtained by. The outer product of
$b$ with
1 in
Equation 7 simply serves to make
$n$ copies of
$b$ so that one copy can
be added to each point in
$G$ .
ones(n,1)
Notification Switch
Would you like to follow the 'A first course in electrical and computer engineering' conversation and receive update notifications?