1.4 The nature of a computer image



In modern computer graphics, an image is solely a rectangular grid, or array of pixels. Beyond what you see on the screen, it is, in reality, a two-dimensional array of numbers. Each number represents the intensity or color of a visible picture element or pixel. The word pixel supposedly stands for picture element.

It is the atomic unit of computer imagery and the smallest area on the view surface that can be accessed by a program. The pixels in an image area themselves little rectangles, all the same size and shape. Each pixel is one solid color throughout. It is important to remember that a pixel is the logical picture element inside the computer.

Locations in CG are stored as mathematical coordinates, but the display surface of an output device is an actual physical object. Thus, it is important to keep in mind the distinction between physical pixels and logical pixels. Physical Pixels are the actual dots displayed on an output device. Each one takes up a small amount of space on the surface of the device.

Physical Pixels are manipulated directly by the display hardware and form the smallest independently programmable physical elements on the display surface. Because physical pixels cover a fixed area on the display surface, there are practical limits to how close together two adjacent pixels can be. On the other hand, logical pixels are like mathematical points: they specify a location, but are assumed to occupy no area. Thus, the mapping between logical pixel values in the bitmap data and physical pixels on the screen must take into account the actual size and arrangement of the physical pixels.


1.4 The nature of a computer image



Figure 1.1 illustrates the difference between physical and logical pixels.

Figure 1.1: Physical and logical pixels.

1.4 The nature of a computer image



The resolution of an image refers to how closely packed the pixels are when displayed.

For example, there may be 37 pixels per millimeter on a computer monitor, or 300 pixels per inch on a color printer. The number of bits in a value used to represent a pixel governs the number of colors the pixel can exhibit. This is called pixel depth which is defined as the number of bits needed to represent their gray levels. The more bits per pixel, the greater the number of possible colors. Accordingly, images are classified into two types:
Gray-Scale (Monochrome) Image.
Colored Image.Gray-Scale image, bitmap, bi-level or 1-bit image are images with two pixel values (0 for white or 1 for black). Note that: N-bit quantity has 2 to the power n gray levels, for example:
2-bits/pixel produces 4 gray levels (00-01-10-11).
4-bits/pixel produce 16 gray levels (Each of the 16 pixel values is represented as 0000 [black]-1111 [white]
8-bits/pixel produce 256 gray levels (000000000-11111111)


1.4 The nature of a computer image



For the colored image, graphics system uses the red, green, blue (RGB) color space.

Colors are defined by specifying three values. These values specify the amount of each of a set of fundamental colors which are mixed to produce composite colors. A composite color is then specified as an ordered set of values. A color is described as separate RGB component and each component vary from 0 to1, meaning black to maximum brightness or intensity. You might characterize colors in the RGB color model as follows:
(0,0,0) means black.
(1,1,1) means white.
(1,1,0) means yellow.


1.4 The nature of a computer image



Figure 1.2 shows the RGB color cube.

This is what you get by mapping the separate red, green, and blue components to the coordinate axes.
Figure 1.2: The red, green, blue (RGB) color cube
The number of bits used to represent the color of each pixel is called Color depth.

Consequently, the highest quality images known as true-color images have a depth of 24 bits (one byte for each component).


1.4 The nature of a computer image



The word true-color comes up in discussions about images that contain a large number of colors. If the space allotted for each color component is a byte (8 bits), the natural range is 0 to 255, with 0 representing zero intensity and 255 representing maximum intensity, so RGB = ([0-255], ([0-255],([0-255]).

When storing color data in a file, it is more practical to specify the value of each color component, not as a percentage, but as a value in a predefined range. For instance, the pixel values for white color= (255, 255, 255), and red color= (255, 0, 0).

This example assumes that 0 stands for the least amount and 255 for the most amount of a particular color component. Another common color space uses three numbers called intensity, hue, and saturation. This approach is closer to the way people think about colors.

Usually, this kind of color space is found in the user interface. The user interacts with the program using intensity, hue, and saturation, which are then converted to RGB for internal use. Intensity is simply how light or dark the color is. Hue describes whether the color is red, blue, Hawaiian coral pink, morning-sunset orange, or whatever. Saturation is the color's boldness or vividness. Pale or washed-out colors have a low saturation. A saturation of 0 means you have a shade of grey.


1.4 The nature of a computer image



Elements of Pictures Created in Computer Graphics

A picture can be described in several ways. We can describe a picture as a set of complex objects, such as trees and terrain or furniture and walls, positioned at specified coordinate locations within the scene. Shapes and colors of the objects can be described internally with pixel arrays or with sets of basic geometric structures, such as straight line segments and polygon color areas.

The basic objects out of which such pictures are composed are called output primitives. In computer graphics, a graphic primitive is something we know how to draw directly into a bitmap, such as a line, a point, and some polygons. Points and straight line segments are the simplest geometric components of pictures. For each primitive there is an attribute associated with it. The attributes of a graphic primitive are the characteristics that affect how it appears, such as color and thickness. For now, we need to understand the basic graphic primitives at our disposal.
Point
What's there to say about a point primitive, is it just a dot, right? Yeah, mostly. In computer graphics the smallest thing we can draw directly is a pixel.
A point is often drawn as one pixel.

1.4 The nature of a computer image



Vector
The word vector can have lots of different meanings.
A computer graphics vector primitive is just a line segment.
It is called a vector mostly for historical reasons.
In computer graphic, however, a vector is just a fancy math term for a direction and a length.
"Two miles east" is an example of a vector.
A vector doesn't have a position, for example, "two miles east from my house" isn't a vector.
A vector is also sometimes said to describe a displacement.
A displacement is just a distance traveled in some direction.
Note that a 3D vector has three degrees of freedom and therefore requires three numbers of storage inside a computer.

1.4 The nature of a computer image



Polyline
A polyline is just a bunch of vectors drawn end to end (i.e. connected sequence of straight lines).
Examples are shown in figure 1.3(a)-(d).
Pictures made up of polylines are sometimes called line drawings.

1.4 The nature of a computer image



Note that a polyline can appear as a smooth curve; refer to figure 1.4 as an example.
Figure 1.4: a curved line made up of straight-line segments


1.4 The nature of a computer image



When there are several lines in a polyline, each one is called an edge, and two adjacent lines meet at a vertex. The edges of a polyline can cross one another.

Polygon
A polyline need not form a closed figure, but if the first and last points are connected by an edge, the polyline is a polygon.
If in addition, no two edges cross, the polygon is called simple.
A mathematical polygon is a bunch of line segments connected end to end in a closed loop.
In computer graphics, we usually care more about the surface inside the line segments, and generally mean that when we use the term polygon.
An important property of a polygon is whether it is convex or concave.
Figure 1.5 shows some 2D examples.
If you draw a line over a convex polygon, the line will cross the polygon only once, no matter where you draw the line.

1.4 The nature of a computer image



For a concave polygon, you can always find a line that crosses the polygon at least twice.
Polygons are fundamental in computer graphics, partly because they are so easy to define, and many drawing algorithms have been finely tuned to operate optimally with polygons.
Figure 1.6 shows some interesting polygons; only A and D are simple.
A polygon is regular if it is simple, if all its sides have equal lengths, and if adjacent sides meet at equal interior angles.
We give the name (n-gon) to regular polygon having n-sides Familiar examples are the 4-gon (a square), 5-gon (a regular pentagon), 8-gon (a regular octagon), and so on.
A 3-gon is an equilateral triangle. Figure 1.7 shows various examples.

1.4 The nature of a computer image



Figure 1.5: Examples of 2D polygon primitives

Figure 1.6: Examples of Polygons

Figure 1.5: Figure 1.7: Examples of n-gons


1.4 The nature of a computer image



Triangle Strip
Most graphics systems know how to draw only very convex polygons, usually triangles.
Triangles are always convex and are the simplest polygons (only three corners).
Many graphics systems have separate primitives for triangles that are more efficient than general polygon primitives
A triangle strip is one row, or "strip" of abutting triangles.
These are often just called "Tstrips".the triangles in a "Tstrips" abut in a regular succession such that only one point is needed to specify each new triangle (see figure 1.8).
This allows the "Tstrips".to be stored, transmitted, and drawn efficiently.


1.4 The nature of a computer image



Figure 1.8: Example of a Triangle Strip Primitive

Quad Mesh Primitive
A quad mesh is the same idea as a Triangle Strip, except that the primitives are quadrilaterals, and an entire mesh instead of just one strip is drawn.

1.4 The nature of a computer image



Quad meshes can be very efficient means to draw complicated surfaces that are defined by a rectangular grid of points (see figure 1.9).

Figure 1.9: Example of a Quad mesh Primitive


1.4 The nature of a computer image



Text
Some graphics devices have two distinct display modes: a text mode and a graphic mode.
The text mode is used to for the simple input and output of characters to control the operating system or edit the code in a program.
The graphics mode offers a richer set of character shapes than the text mode does, and characters can be placed arbitrarily.
Figure 1.10 shows some examples of text drawn graphically.

1.4 The nature of a computer image



There are many text attributes, the most important of which are the text's font (type-face), color size, spacing, and orientation.

Figure 1.10: Some text drawn graphically


1.4 The nature of a computer image



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.11 shows several filled polygons.
Figure 1.12 shows the use of filled regions to shade the different faces of three-dimensional object.
The attributes of a filled region include the attributes of the enclosing border that encloses the region, as well as the pattern and color of the filling.

1.4 The nature of a computer image



Algorithms for performing the filling action with OpenGL will be discussed in chapter 3.

Figure 1.11: Examples of filled polygons


1.4 The nature of a computer image



Figure 1.12: Examples of filled polygons

A raster image is stored in a computer as an array of numerical values.
Each numerical value represents the value of the pixel stored there. The array as a whole is often called a "pixel map".
Figure 1.13(a) shows a simple example of a figure that is represented by a 18-by-19 array (18 row by 19 columns) of cells in three shade of gray.

1.4 The nature of a computer image



Suppose that the three grey levels are encoded as the values 1, 2, and 7.
Figure 1.13(b) shows the numerical values of the pixel map for the upper left 6-by-8 portion of the image.

Figure 1.13: A simple figure represented as a bitmap


1.4 The nature of a computer image



There are three principle sources for creating raster images:
  1. Hand-designed images: with this technique, designer figures out what values are needed for each cell and type them into memory. Sometimes a paint program can be used to help automate the process. The icon in figure 1.13 was created this way.
  2. Computed images: an algorithm is used to render a scene, which might be modeled abstractly in computer memory.
  3. Scanned images: a photograph or television image can be digitized. In effect, a grid is placed over the original image, and at each grid point, the digitizer reads into memory the closest color in its repertoire. The bitmap thereby created is then stored in a file for later use. The image of the kitty in figure 1.14 was formed in this way.
Figure 1.14: A scanned image


1.4 The nature of a computer image



Color Raster Images
Color raster images have become more common in recent years as the cost of high-quality color displays has come down.
Each pixel in a color image has a color value, a numerical value that somehow represents a color.
One of the most common ways to associate numbers with colors is to describe a color as a combination of amounts of red, green, and blue light.
Each pixel value is an ordered triple such as (23,14,51), that prescribes the intensities of the red, green, and blue components in that order.
The number of bits used to represent the color of each pixel is often called the color depth of the pixel.
The highest quality images, known as true-color images, have a color depth of 24 and so use a byte for each component.


1.4 The nature of a computer image




1.4 The nature of a computer image




1.4 The nature of a computer image




1.4 The nature of a computer image




1.4 The nature of a computer image




1.4 The nature of a computer image