Skip to content Skip to navigation

OpenStax_CNX

You are here: Home » Content » Vector Graphics: Two-Dimensional Image Representation

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Endorsed by Endorsed (What does "Endorsed by" mean?)

This content has been endorsed by the organizations listed. Click each link for a list of all content endorsed by the organization.
  • IEEE-SPS

    This module is included inLens: IEEE Signal Processing Society Lens
    By: IEEE Signal Processing SocietyAs a part of collection: "A First Course in Electrical and Computer Engineering"

    Click the "IEEE-SPS" link to see all content they endorse.

  • College Open Textbooks display tagshide tags

    This module is included inLens: Community College Open Textbook Collaborative
    By: CC Open Textbook CollaborativeAs a part of collection: "A First Course in Electrical and Computer Engineering"

    Comments:

    "Reviewer's Comments: 'I recommend this book as a "required primary textbook." This text attempts to lower the barriers for students that take courses such as Principles of Electrical Engineering, […]"

    Click the "College Open Textbooks" link to see all content they endorse.

    Click the tag icon tag icon to display tags associated with this content.

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • Bookshare

    This module is included inLens: Bookshare's Lens
    By: Bookshare - A Benetech InitiativeAs a part of collection: "A First Course in Electrical and Computer Engineering"

    Comments:

    "Accessible versions of this collection are available at Bookshare. DAISY and BRF provided."

    Click the "Bookshare" link to see all content affiliated with them.

  • NSF Partnership display tagshide tags

    This module is included inLens: NSF Partnership in Signal Processing
    By: Sidney BurrusAs a part of collection: "A First Course in Electrical and Computer Engineering"

    Click the "NSF Partnership" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

  • Featured Content display tagshide tags

    This module is included inLens: Connexions Featured Content
    By: ConnexionsAs a part of collection: "A First Course in Electrical and Computer Engineering"

    Comments:

    "A First Course in Electrical and Computer Engineering provides readers with a comprehensive, introductory look at the world of electrical engineering. It was originally written by Louis Scharf […]"

    Click the "Featured Content" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

Also in these lenses

  • UniqU content

    This module is included inLens: UniqU's lens
    By: UniqU, LLCAs a part of collection: "A First Course in Electrical and Computer Engineering"

    Click the "UniqU content" link to see all content selected in this lens.

  • Lens for Engineering

    This module is included inLens: Lens for Engineering
    By: Sidney Burrus

    Click the "Lens for Engineering" link to see all content selected in this lens.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.
 

Vector Graphics: Two-Dimensional Image Representation

Module by: Louis Scharf. E-mail the author

Note:

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 Pi=(xi,yi)Pi=(xi,yi) is such an endpoint, we write it as the column vector

pi=xiyipi=xiyi
(1)

Suppose there are n 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 the vectors Pi Pi 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 . 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 .
(2)

We then store the point matrix GR2xnGR2xn as a two-dimensional array in computer memory.

Example 1

Consider the list of points

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

The corresponding point matrix is

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

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

hk=ikjk.hk=ikjk.
(5)

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

H = i 1 i 2 i 3 ... i m j 1 j 2 j 3 ... j m . H = i 1 i 2 i 3 ... i m j 1 j 2 j 3 ... j m .
(6)

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

Example 2

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

H1=12342341.H1=12342341.
(7)

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

H2=12332314.H2=12332314.
(8)

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

Figure 1: Two Sets of Lines
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.

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

function vgraphl (points, lines);
% vgraphl (points, lines) plots the points as *'s and
% connects the points with specified lines. The points
% matrix should be 2xN, and the lines matrix should be 2xM.
% The field of view is preset to (-50,50) on both axes.
%
% Written by Richard T. Behrens, October 1989
%
m=length(lines);                    % find the number of
                                    % lines.
axis([-50 50 -50 50])               % set the axis scales
axis('square')
plot(points(1,:),points(2,:),'*')   % plot the points as *
hold on                             % keep the points...
for i=i:m                           % while plotting the
                                    % lines
    plot([points(1,lines(1,i)) points(1,lines(2,i))],..
        [points(2,lines(2,lines(1,i)) points(2,lines(2,i))],'-')
    
    end
    
    hold off

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

>> G = [
    0.6052 -0.4728;
   -0.4366  3.5555;
   -2.6644  7.9629;
   -7.2541 10.7547;
  -12.5091 11.5633;
  -12.5895 15.1372;
   -6.5602 13.7536;
  -31.2815 -7.7994;
  -38.8314 -9.9874;
  -44.0593 -1.1537;
  -38.8314  2.5453;
  -39.4017  9.4594;
  -39.3192 15.0932;
  -45.9561 23.4158]

>> G = G'

>> H = [
   1   2;
   2   3;
   3   4;
   4   5;
   4   7;
   5   6;
   8   9;
   9   10;
   10  11;
   11  12;
   12  13;
   12  14]

>> H = H'

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

>> save dippers

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

≫ vgraph1(G,H)

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 G. The line information in H 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 will be 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 points and 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 with that object. Each column is defined as

k i = first point last point first line last line . k i = first point last point first line last line .
(9)

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

Example 3

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

K=187l417612.K=187l417612.
(10)

The first column of K 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 K defines the second object (Ursa Major) as points 8 through 14 and lines 7 through 12.

Content actions

Download module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks