<< Chapter < Page Chapter >> Page >
This module is part of the collection, A First Course in Electrical and Computer Engineering . The LaTeX source files for this collection were created using an optical character recognition technology, and because of this process there may be more errors than usual. Please contact us if you discover any errors.

Point Matrix. To represent a straight-line image in computer memory, we must store a list of all the endpoints of the line segments that comprise the image. If the point P i = ( x i , y i ) is such an endpoint, we write it as the column vector

p i = x i y i

Suppose there are n such endpoints in the entire image. Each point is included only once, even if several lines end at the same point. We can arrange thevectors P i into a point matrix:

G = [ p 1 p 2 p 3 . . . p n ] = x 1 x 2 x 3 x n y 1 y 2 y 3 y n .

We then store the point matrix G R 2 x n as a two-dimensional array in computer memory.

Consider the list of points

P 1 = ( 0 , 0 ) P 2 = ( - 1 . 5 , 5 ) P 3 = ( 4 , 2 . 3 ) P 4 = ( 4 , - 1 ) .

The corresponding point matrix is

G = 0 - 1 . 5 4 4 0 5 2 . 3 - 1 ·

Line Matrix. The next thing we need to know is which pairs of points to connect with lines. To store this information for m lines, we will use a line matrix, H R 2 × m . The line matrix does not store line locations directly. Rather, it contains references to the points stored in G . To indicate a line between points p i and p j , we store the indices i and j as a pair. For the k t h line in the image, we have the pair

h k = i k j k .

The order of i and j does not really matter since a line from p i to p j is the same as a line from p j to p i . Next we collect all the lines h k into a line matrix H :

H = i 1 i 2 i 3 ... i m j 1 j 2 j 3 ... j m .

All the numbers in the line matrix H will be positive integers since they point to columns of G . To find the actual endpoints of a line, we look at columns i and j of the point matrix G .

To specify line segments connecting the four points of Example 1 into a quadrilateral, we use the line matrix

H 1 = 1 2 3 4 2 3 4 1 .

Alternatively, we can specify line segments to form a triangle from the first three points plus a line from P 3 to P 4 :

H 2 = 1 2 3 3 2 3 1 4 .

Figure 1 shows the points G connected first by H 1 and then by H 2 .

Figure 1 contains two basic cartesian graphs with sets of lines connected at unspecific points. Both graphs are labeled with horizontal axis, x, and vertical axis, y. The first graph contains four line segments joined together by numbered dots that create a quadrilateral. Point one is at the origin. Point two is in the second quadrant, closer to the vertical axis than the horizontal axis. Point three is in the first quadrant, approximately equidistant from both axes. Point four is in the fourth quadrant directly below point three, and is much closer to the horizontal axis than the vertical axis. The second graph contains four line segments, although they are not connected to form a quadrilateral, rather a triangle with one segment connected to a vertex. All four points in the second graph are in the same spots as in the first graph. The line segments connecting one to two, two to three, and three to four are also in the same place, but instead of four connecting directly with one, there is a line segment connecting three with one. Figure 1 contains two basic cartesian graphs with sets of lines connected at unspecific points. Both graphs are labeled with horizontal axis, x, and vertical axis, y. The first graph contains four line segments joined together by numbered dots that create a quadrilateral. Point one is at the origin. Point two is in the second quadrant, closer to the vertical axis than the horizontal axis. Point three is in the first quadrant, approximately equidistant from both axes. Point four is in the fourth quadrant directly below point three, and is much closer to the horizontal axis than the vertical axis. The second graph contains four line segments, although they are not connected to form a quadrilateral, rather a triangle with one segment connected to a vertex. All four points in the second graph are in the same spots as in the first graph. The line segments connecting one to two, two to three, and three to four are also in the same place, but instead of four connecting directly with one, there is a line segment connecting three with one.
Two Sets of Lines

Demo 1 (MATLAB) . Use your editor to enter the following MATLAB function file. Save it as vgraphl.m.

After you have saved the function file, run MATLAB and type the following to enter the point and line matrices. (We begin with the transposesof the matrices to make them easier to enter.)

At this point you should use MATLAB's “save” command to save these matrices to a disk file. Type

After you have saved the matrices, use the functionto draw the image by typing VGRAPH1

The advantage of storing points and lines separately is that an object can be moved and scaled by operating only on the point matrix G . The line information in H remains the same since the same pairs of points are connected no matter where we put the points themselves.

Surfaces and Objects. To describe a surface in three dimensions is a fairly complex task, especially if the surface is curved. For this reason, we willbe satisfied with points and lines, sometimes visualizing flat surfaces based on the lines. On the other hand, it is a fairly simple matter to group the pointsand lines into distinct objects . We can define an object matrix K with one column for each object giving the ranges of points and lines associated withthat object. Each column is defined as

k i = first point last point first line last line .

As with the line matrix H , the elements of K are integers.

Consider again Demo 1 . We could group the points in G and the lines in H into two objects with the matrix

K = 1 8 7 l 4 1 7 6 12 .

The first column of K specifies that the first object (Ursa Minor) is made up of points 1 through 7 and lines 1 through 6, and the second column of K defines the second object (Ursa Major) as points 8 through 14 and lines 7 through 12.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, A first course in electrical and computer engineering. OpenStax CNX. Sep 14, 2009 Download for free at http://cnx.org/content/col10685/1.2
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'A first course in electrical and computer engineering' conversation and receive update notifications?

Ask