Sie sind auf Seite 1von 19

Chapter 1

[Francis S. Hill, Jr., Stephen M. Kelley. 2006. Computer Graphics Using OpenGL, 3rd Ed. Prentice Hall. ISBN: 0131496700.] GOALS OF THE CHAPTER To provide an overview of the computer graphics field. To describe the important input and output graphics devices. Preview Section 1.1 introduces the area of computer graphics, and Section 1.2 gives a number of examples of how computer graphics are used today. Section 1.3 looks at the primitive ingredients that make a computer generated picture. In particular, Section 1.3.4 introduces the notion of a raster image that is used throughout the book. In Section 1.4 we describe a number of graphics display devices that are in common use today, and Section 1.5 surveys various input devices that are used in interactive graphics applications.

Introduction to Computer Graphics

1.1 What is Computer Graphics?


Computer graphics are pictures that are generated by a computer.

FIGURE 1.1 A ray-traced image including reflections and shadows. (Courtesy of Sven Maerivoet) Hardware tools used for computer graphics include - video monitors: - graphics cards: ATI, NVIDIA - input devices: keyboard, mouse, data glove, trackball, and so on. Software tools used for computer graphics include - operating system: Windows, Unix (Linux), Mac OS - programming languages: C/C++, Java, Visual Basic, C#, and so on. - graphics libraries/API: OpenGL, DirectX, and so on. Computer graphics often means the whole field of study that involves hardware and software tools and the pictures they produce. The graphics special interest groups are 1

- SIGGRAPH: http://www.siggraph.org. - The ACM Transactions on Graphics [TOG] http://tog.acm.org/ (ACM: The Association for Computing Machinery) - The IEEE Computer Graphics and Applications http://www.computer.org/portal/web/cga/home IEEE Xplore (IEEE: The Institute of Electrical and Electronics Engineers)

1.2 Where Computer-Generated Pictures Are Used


Some applications of computer graphics are 1.2.1 Art, Entertainment, and Publishing Computer Games

FIGURE 1.2 A screen shot from a 3D computer-based game. (Courtesy of High Moon Studios, Inc.)

FIGURE 1.4 A screen shot of Wolfenstein 3D. (Courtesy of iD Software) Movie Production, Animation, and Special Effects Browsing on the World Wide Web

FIGURE 1.5 Screenshot of a page from the World Wide Web. (Courtesy of Intangible Inc.) Slide, Book, and Magazine Design

FIGURE 1.6 Example slide for an educational presentation. Paint systems: MS Paint, Adobe Photoshop, zBrush, and so on.

FIGURE 1.7 Screenshot of a paint system. (Courtesy of zBrush) 1.2.2 Computer Graphics and Image Processing The main task in computer graphics is to create pictures and images, synthesizing them based on some description or model, in a computer. The main task in image processing is to improve or alter images that were created elsewhere, perhaps digitized from photographs or captured by a video recorder.

FIGURE 1.8 Enhancing a scanned image: a) origin, b) enhanced. 1.2.3 Monitoring a Process Highly complex systems like factories, power plants, and air traffic control systems must be carefully monitored; often there must be a human in the loop to watch out for impending trouble. A status display must give the operator up-to-the moment information to be interpreted instantly. Measurements are made of the system every second or as needed, and the data are transmitted to the monitoring station, converted to graphical information, and presented to the operator. 1.2.4 Displaying Simulations The classic simulation example is a flight simulator.

FIGURE 1.9 Simulation of the control panel of an actual airplane. (Courtesy of hegyi) Computer graphics has the ability to display objects as if they already physically exist, when in actuality they are only models inside a computer. 1.2.5 Computer-Aided Design: CAD A wireframe drawing is the shape of an object that is rendered by connected lines. Example: Figure 1.14c. Computer-aided Architectural Design (CAAD)

FIGURE 1.10 A floor plan of a hospital. (Courtesy of Carling Animal Hospital & ema ARCHITECTURE Inc. Ottawa Ont.) 1.2.6 Scientific Analysis and Volume Visualization

FIGURE 1.11 Display of complex scientific data. Volume Visualization: Graphics is used to display huge amounts of data (e.g., weather patterns).

FIGURE 1.12 View of the human brain using volume visualization. (Courtesy of Dr. Richard Rubin, UMASS-Amherst)

FIGURE 1.13 Display by Mathematica of a) a complex mathematical surface, and b) a mathematically defined solid object.

1.3 Elements of Pictures Created in Computer Graphics


Output primitives are - points - lines - polylines, polygons - text - filled regions - raster images The attributes of a graphic primitive are the characteristics that affect how it appears, such as drawing color, point size, line thickness, line pattern (e.g., solid, dash, dotted). 1.3.1 Polylines

FIGURE 1.14 a) A polyline drawing of a dinosaur, b) a plot of a mathematical function, c) a wireframe rendering of a 3D object.

A polyline is a sequence of connected line segments.

FIGURE 1.15 A curved line made up of straight line segments. Pictures made up of polylines are sometimes called line drawings.

FIGURE 1.16 An example of polyline. If the first and last points of a polyline are connected by an edge, the polyline is called a polygon. If, in addition, no two edges cross, the polygon is called simple.

FIGURE 1.17 Examples of polygons. Attributes of Lines and Polylines: Important attributes of a polyline are the drawing color, thickness, and pattern (solid, dashed, dotted).

FIGURE 1.18 Polyline with different attributes.

1.3.2 Text

FIGURE 1.20 Some examples of text drawn graphically. Two display modes in graphics devices are text mode and graphics mode. Text Attributes: important attributes of text are typeface (font), color, size, spacing, and orientation.

FIGURE 1.21 Some examples of fonts.

FIGURE 1.22 A character shape defined by a) a polyline and by b) a pattern of dots. 1.3.3 Filled Regions The filled region (sometimes called fill area) primitive is a shape filled with some color or pattern. The boundary of a filled region is often a polygon.

FIGURE 1.23 Examples of filled polygons. Figure 1.24 shows the use of filled regions to shade the different faces of a 3D object (shading).

FIGURE 1.24 Filling polygonal faces of 3D objects to suggest proper shading. 1.3.4 Raster Images [Rafael C. Gonzalez, Richard E. Woods. 2007. Digital Image Processing. 3rd Ed. Prentice Hall. ISBN: 013168728X.] A raster image I is stored in a 2-dimensional array (matrix) sized HW. The element located at row i and column j is called pixels (short for picture elements) and denoted as pij or I[i][j], where 0 i H and 0 j W. -

FIGURE 1.25 a) A raster image of chess piece, b) a magnification of the image. (Courtesy of Andrew Slater)

FIGURE 1.26 A simple figure represented as a bitmap (or pixel map). Three principal ways of creating a raster image are: 1. Hand-designed images 2. Computed images 3. Scanned images

FIGURE 1.27 a) A collection of lines and text, b) magnification of part a, having jaggies, c) individual pixels visible in an extreme close up.

FIGURE 1.28 A scanned image.

10

FIGURE 1.29 Three successive blow-ups of the kitten image: a) three times enlargement, b) six times enlargement, and c) twelve times enlargement.

FIGURE 1.30 Examples of image enhancement.

FIGURE 1.31 a) The embossed image, b) geometrically distorted image. 1.3.5 Representation of Gray Shades and Color for Raster Images [Rafael C. Gonzalez, Richard E. Woods. 2007. Digital Image Processing. 3rd Ed. Prentice Hall. ISBN: 013168728X.] Pixel depth is the number of bits needed to represent gray levels/values of an image. Since an n-bit quantity has 2n possible values, there can be 2n gray levels in an image with pixel depth n. The most common values of n:

11

1 bit/pixel produces 2 gray levels (pij {0, 1}): binary image 8 bits/pixel produce 256 gray levels (0 pij 255): grayscale image

FIGURE 1.32 a) A bilevel image of a cursor, and b) its bitmap. Grayscale Raster Images

Monochrome Lena

Grayscale Lena

Color Baboon

Effect of Pixel Depth: Grayscale Quantization

FIGURE 1.34 The image of Figure 1.28 reduced to a) 6 bits/pixel, and b) 3 bits/pixel.

12

FIGURE 1.35 The image of Figure 1.28 reduced to a) 2 bits/pixels and b) 1 bit/pixel. Color Raster Images Each pixel in a color image has a color value, a numerical value that somehow represents a color. There are a number of ways to associate numbers and colors, but one of the most common is to describe a color as a combination of amounts of red, green, and blue light. Each pixel value is a 3-tuple, such as (R, G, B) = (23, 14, 51), that prescribes the intensities of the red, green, and blue light components in that order, where 0 R, G, B 255. Color depth is the number of bits used to represent the color of each pixel. The colors red, green, and blue are called primaries. Each value in the (red, green, blue) 3-tuple has a certain number of bits, and the color depth is the sum of these values. A color depth of three allows one bit for each component. For instance, the pixel value (0, 1, 1) means that the red component is off, but both green and blue are on. In most displays the contributions from each component are added together, so (0, 1, 1) would represent the addition of green and blue light, which is perceived as cyan. Since each component can be on or off, there are eight possible colors, as tabulated in Figure 1.36. As expected, equal amounts of red, green, and blue, (1, 1, 1), produce white.

FIGURE 1.36 A common correspondence between color value and perceived color. A color depth of three rarely offers enough precision for specifying the value of each component, so larger color depths are used. Because a byte is such a natural quantity to manipulate on a computer, many images have a color depth of twenty-four, or 8 bits per primary.

13

Each pixel then can have 224 or over 2 billion colors. Such images are known as true color images and have as good color reproduction as the eye can perceive.

1.4 Graphics Display Devices


1.4.1 Line Drawing Displays Video displays that produce line drawings are called vector, random-scan, or calligraphic displays. 1.4.2 Raster Displays Most displays used today for computer graphics are raster displays. The most familiar is the video monitor connected to a personal computer or workstation (see Figure 1.38).

FIGURE 1.38 a) A video monitor on a PC, b) flat screen displaying x-rays. Raster devices have a display surface on which the image is presented. The surface is organized as a certain #, say 480, of rows and a certain #, say 640, of columns. Such displays have a built-in coordinate system, as shown in Figure 1.39, that associates a given pixel in an image with a given physical position on the display surface. The horizontal coordinate sx increases from left to right, and the vertical coordinate sy increases from top to bottom. This upside-down coordinate system is common in raster devices.

FIGURE 1.39 The built-in coordinate system for the surface of a raster display.

14

A planar point in a screen coordinate system (abscissa, ordinate) = (x, y) is the point (x, H - y) in a window coordinate system, where H is the screen height. Raster displays are always connected one way or another to a frame buffer, a region of memory sufficiently large to hold all of the pixel values for the display (i.e., to hold the bitmap). The frame buffer may be physical memory on-board the display, or it may reside in the host computer. Alternatively, a graphics card installed in a personal computer might house the memory required for the frame buffer. Figure 1.40 suggests how an image is created and displayed. The graphics program is stored in system memory and is executed instruction by instruction by the central processing unit (CPU). The program computes an appropriate value for each pixel and loads it into the frame buffer.

FIGURE 1.40 Block diagram of a computer with raster display. A scan controller takes care of the actual display process. It runs autonomously (rather than under program control) and does the same thing pixel after pixel. It causes the frame buffer to send each pixel through a converter to the appropriate physical locations on the display surface. The converter takes a pixel value such as 01001011 and converts it to the corresponding colorvalue quantity that produces a spot of color on the display. The Scanning Process Figure 1.41 provides more detail on the scanning process.

FIGURE 1.41 Scanning out an image from the frame buffer to the display surface. Video Monitors

15

Many video monitors are based on a CRT (cathode-ray tube).

FIGURE 1.42 Operation of a color video monitor display system. DACs (digital-to-analog converters) convert logical values like 01 into actual voltages. The correspondence between digital input values and output voltages is shown in Figure 1.43, where Max is the largest voltage level the DAC can produce. Input Voltage/Brightness 00 0 * Max 01 0.333 * Max 10 0.666 * Max 11 1 * Max FIGURE 1.43 Input-output characteristic of a 2-bit DAC. Scanning proceeds row by row through the frame buffer, and each row provides pixel values for one scanline across the face of the CRT. The order of scanning is usually left to right along a scanline and from top to bottom by scanline (called raster scan order). This convention has given rise to the habit of numbering scanlines downward with 0 at the top, resulting in upside-down coordinate systems. 1.4.3 Video Cards/3D Accelerators

16

FIGURE 1.44 A video card from ATI Technologies. (A color version is available in Plate 5). (Courtesy of ATI) Graphics card or 3D graphics accelerator. This hardware has special circuitry designed to respond very rapidly to requests for data transfer from the CPU to the display. Graphics cards are more expensive than older display adapters; todays accelerators contain large amounts of onboard memory. Whenever an image is being formed, the geometric data that define the scene must pass through a large number of processing steps: OpenGL simply specifies the nature of these steps and the order in which they must occur. These steps are referred to as the graphics pipeline, which we discuss at various points throughout the book. 1.4.4 Other Raster Display Devices Other video monitors are flat panel display, liquid crystal display (LCD), plasma panel display, and so on.

17

FIGURE 1.45 Flat panel displays.

1.5 Graphics Input Primitives and Devices


1.5.1 Types of Logical Input Graphics Primitives The important logical input primitives are: String The string device is the most familiar, producing a string of characters and thus modeling the action of a keyboard. When an application requests a string, the program pauses while the user types it in, followed by a termination character. The program then resumes with the string stored in memory. Valuator A valuator produces a real value between 0.0 and 1.0, which can be used to fix the length of a line, the speed of an action, or perhaps the size of a picture. Locator A basic requirement in interactive graphics is to enable the user to point to a position on the display. The locator input device performs this function, because it produces a coordinate pair (x, y). The user manipulates an input device (usually a mouse) in order to position a visible cursor to some spot and then triggers the choice. This returns to the application the values of x and y, along with the trigger value. a) b)

FIGURE 1.48 a) A POS system, b) close-up of touch screen in the POS system. (Courtesy of Action Systems)

18

Pick The pick input device is used to identify a portion of a picture for further processing. Some graphics packages allow a picture to be defined in terms of segments, which are groups of related graphics primitives. The touch screen (shown in Figure 1.48b) of the POS system defines segments and gives the user identifying names to expedite the ordering process. 1.5.2 Types of Physical Input Devices Common input devices are keyboard, mouse with left, right, and middle buttons.

FIGURE 1.49 A graphics tablet. (Courtesy of Wacom Inc.) a) b) c)

FIGURE 1.50 a) A joystick, b) a trackball, c) data glove (Courtesy of 5DT)

1.6 Chapter Summary


The most widely used of drawing device is the raster video. The major output primitives are points, line segments, polylines, regions, text, and raster images. The attributes of output primitives are point size, line thickness, line pattern (solid, dashed, and dotted). Input devices (input primitives) used for interactive computer graphics are keyboard, mouse, joystick, data glove, and so on.

19

Das könnte Ihnen auch gefallen