Computer Graphics and Animation
Computer Graphics and Animation
2024
Lecturer: ACHOH S. TIMAH
As time went on, and the capacity and speed of computer technology improved, successively
greater degrees of realism were achievable. Today it is possible to produce images that are
practically indistinguishable from photographic images.
Unit 1: COMPUTER GRAPHICS AND APPLICATIONS
1.0 Introduction
2.0 Objectives
3.0 Main Content
3.1 Definition of Computer Graphics
3.2 History
3.3 Application of Computer Graphics
3.4 What is Interactive Computer Graphics?
3.5 What do we need in Computer Graphics?
3.6 The Graphics Rendering Pipeline
4.0 Conclusion
5.0 Summary
6.0 Tutor Marked Assignment
1.0 Introduction
Given the state of current technology, it would be possible to design an entire university
major to cover everything (important) that is known about computer graphics. In this
introductory course, we will attempt to cover only the merest fundamentals upon which the
field is based. Nonetheless, with these fundamentals, you will have a remarkably good
insight into historical development of Computer graphics, the various application areas and
the graphics rendering pipeline.
2.0 Objectives
Upon successful completion of this unit, students will:
• have an understanding of the history of computer graphics
• have gained an appreciation for the art of computer graphics
• Understand the basic Graphic rendering pipeline.
3.1 Definition of Computer Graphics.
Computer graphics generally means creation, storage and manipulation of models and
images. Such models come from diverse and expanding set of fields including physical,
mathematical, artistic, biological, and even conceptual (abstract) structures.
“Perhaps the best way to define computer graphics is to find out what it is not. It is not a
machine. It is not a computer, nor a group of computer programs. It is not the know-how of
a graphic designer, a programmer, a writer, a motion picture specialist, or a reproduction
specialist.
Computer graphics is all these –a consciously managed and documented technology
directed toward communicating information accurately and descriptively.
3.2 History
3.1.1 The Age of Sutherland
In the early 1960's IBM, Sperry-Rand, Burroughs and a few other computer companies
existed. The computers of the day had a few kilobytes of memory, no operating systems to
speak of and no graphical display monitors. The peripherals were Hollerith punch cards, line
printers, and roll-paper plotters. The only programming languages supported were
assembler, FORTRAN, and Algol. Function graphs and “Snoopy'' calendars were about the
only graphics done.
In 1963 Ivan Sutherland presented his paper Sketchpad at the Summer Joint Computer
Conference. Sketchpad allowed interactive design on a vector graphics display monitor with
a light pen input device. Most people mark this event as the origins of computer graphics.
3.2.5 Games
Games are an important driving force in computer graphics. In this class we are going to talk
about games. We'll discuss on how they work. We'll also question how they get so much
done with so little to work with.
3.2.6 Entertainment
If you can imagine it, it can be done with computer graphics. Obviously, Hollywood has
caught on to this. Each summer, we are amazed by stateof-the-art special effects. Computer
graphics is now as much a part of the entertainment industry as stunt men and makeup. The
entertainment industry plays many other important roles in the field of computer graphics.
The scene composed of models in three space. Models, composed of primitives, supported
by the rendering system. Models entered by hand or created by a program.
For our purposes today, models already generated. The image drawn on monitor, printed on
laser printer, or written to a raster in memory or a file. These different possibilities require
us to consider device independence.
Classically, “model” to “scene”' to “image” conversion broken into finer steps, called the
graphics pipeline. Commonly implemented in graphics hardware to get interactive speeds.
At a high level, the graphics pipeline usually looks like
Each stage refines the scene, converting primitives in modelling space to primitives in device
space, where they are converted to pixels (rasterized).
A number of coordinate systems are used:
4.0 Conclusion
Computer graphics (CG) is the field of visual computing, where one utilizes computers both
to generate visual images synthetically and to integrate or alter visual and spatial
information sampled from the real world.
5.0 Summary
In this unit, we have learnt
i. the evolution of computer graphics from the early days to the recent times, the
technological innovations
ii. The various application areas of computer graphics
iii. What is needed in computer graphics
iv. Graphics rendering pipeline.
1.0 Introduction
2.0 Objectives
3.0 Main Content
3.1 Types of input devices
3.2 Graphics Software
3.3 OpenGL
3.4 Hardwar
3.5 Display Hardware
4.0 Conclusion
5.0 Summary
6.0 Tutor-Marked Assignment
1.0 Introduction
Computer graphics don’t work in isolation. They require Hardware- the physical component
that houses the software. The software tools to create graphics applications are also needed
and display devices for effective output are not left. These and their functionalities, we shall
discuss in this unit.
2.0 Objectives
At the completion of this unit, the students are expected to get acquainted with the
following:
3.3 Hardware
“Vector graphics” Early graphic devices were line-oriented. For example, a “pen plotter”
from H-P. Primitive operation is line drawing. “Raster graphics” Today’s standard. A raster is
a 2-dimensional grid of pixels (picture elements). Each pixel may be addressed and
illuminated independently. So the primitive operation is to draw a point; that is, assign a
color to a pixel. Everything else is built upon that. There are a variety of raster devices, both
hardcopy and display.
Hardcopy:
Laserprinter
Ink-jet printer
Film recorder
Electrostatic printer
Pen plotte
1. The display screen is coated with “phospors” which emit light when excited by an
electron beam. (There are three types of phospor, emitting red, green, and blue light.) They
are arranged in rows, with three phospor dots (R, G, and B) for each pixel.
2. The energy exciting the phosphors dissipates quickly, so the entire screen must be
refreshed 60 times per second.
3. An electron gun scans the screen, line by line, mapping out a scan pattern. On each
scan of the screen, each pixel is passed over once. Using the contents of the frame buffer,
the controller controls the intensity of the beam hitting each pixel, producing a certain color.
Electron gun sends beam aimed (deflected) at a particular point on the screen, Traces out a
path on the screen, hitting each pixel once per cycle. “scan lines” · Phosphors emit light
(phosphoresence); output decays rapidly (exponentially - 10 to 60 microseconds) · As a
result of this decay, the entire screen must be redrawn (refreshed) at least 60 times per
second. This is called the refresh rate. If the refresh rate is too slow, we will see a noticeable
flicker on the screen. CFF (Critical Fusion Frequency) is the minimum refresh rate needed to
avoid flicker. This depends to some degree on the human observer. Also depends on the
persistence of the phosphors; that is, how long it takes for their output to decay. · The
horizontal scan rate is defined as the number of scan lines traced out per second. · The most
common form of CRT is the shadow-mask CRT. Each pixel consists of a group of three
phosphor dots (one each for red, green, and blue), arranged in a triangular form called a
triad. The shadow mask is a layer with one hole per pixel. To excite one pixel, the electron
gun (actually three guns, one for each of red, green, and blue) fires its electron stream
through the hole in the mask to hit that pixel. · The dot pitch is the distance between the
centers of two triads. It is used to measure the resolution of the screen.
(Note: On a vector display, a scan is in the form of a list of lines to be drawn, so the time to
refresh is dependent on the length of the display list.)
A liquid crystal display consists of 6 layers, arranged in the following order (back-to-front):
How it works:
The liquid crystal rotates the polarity of incoming light by 90 degrees. Ambient light is
captured, vertically polarized, rotated to horizontal polarity by the liquid crystal layer, passes
through the horizontal filter, is reflected by the reflective layer, and passes back through all
the layers, giving an appearance of lightness. However, if the liquid crystal molecules are
charged, they become aligned and no longer change the polarity of light passing through
them. If this occurs, no light can pass through the horizontal filter, so the screen appears
dark.
The principle of the display is to apply this charge selectively to points in the liquid crystal
layer, thus lighting or not lighting points on the screen. Crystals can be dyed to provide color.
An LCD may be backlit, so as not to be dependent on ambient light.
TFT (thin film transistor) is most popular LCD technology today. Plasma Display Panels.
Promising for large format displays
Basically fluorescent tubes
High-voltage discharge excites gas mixture (He, Xe)
Upon relaxation UV light is emitted
UV light excites phosphors
Large viewing angle
Raster Architecture
Raster display stores bitmap/pixmap in refresh buffer, also known as bitmap, frame buffer;
be in separate hardware (VRAM) or in CPU’s main memory (DRAM) Video controller draws
all scan-lines at Consistent >60 Hz; separates update rate of the frame buffer and refresh
rate of the CRT.
(Note: In early PCs, there was no display processor. The frame buffer was part of the physical
address space addressable by the CPU. The CPU was responsible for all display functions.)
Some Typical Examples of Frame Buffer Structures:
1. For a simple monochrome monitor, just use one bit per pixel.
2. A gray-scale monitor displays only one color, but allows for a range of intensity levels
at each pixel. A typical example would be to use 6-8 bits per pixel, giving 64-256 intensity
levels. For a color monitor, we need a range of intensity levels for each of red, green, and
blue. There are two ways to arrange this.
3. A color monitor may use a color lookup table (LUT). For example, we could have a LUT
with 256 entries. Each entry contains a color represented by red, green, and blue values. We
then could use a frame buffer with depth of 8. For each pixel, the frame buffer contains an
index into the LUT, thus choosing one of the 256 possible colors. This approach saves
memory, but limits the number of colors visible at any one time.
4. A frame buffer with a depth of 24 has 8 bits for each color, thus 256 intensity levels for
each color. 224 colors may be displayed. Any pixel can have any color at any time. For a
1024x1024 monitor we would need 3 megabytes of memory for this type of frame buffer.
The display processor can handle some medium-level functions like scan conversion
(drawing lines, filling polygons), not just turn pixels on and off. Other functions: bit block
transfer, display list storage. Use of the display processor reduces CPU involvement and bus
traffic resulting in a faster processor. Graphics processors have been increasing in power
faster than CPUs, a new generation every 6-9 months. example: 10 3E. NVIDIA GeForce FX.
4.0 Conclusion
Computer graphics ultimately involves creation, storage and manipulation of models and
images. This however is made realistic through effective hardware, software and display
devices.
5.0 Summary
In this module, we have leant that:
i. Input devices are of various types and can further be categorized.
ii. Computer Graphics software are the software require to run computer graphics.
iii. There are different display hardware such as the LCD, CRT, etc. Also learnt about their
architecture and functionality
6.0 Tutor’s Assignment
1. Explain about the display technologies?
2. Explain various display devices?
3. What are the different hardware and software of graphics?
4. List five graphic hard copy devices and for each one, briefly explain
- How it works.
- Its advantages and limitations.
- The circumstances when it would be more useful.
Unit 3: GRAPHICS DATA STRUCTURES
Contents
1.0 Introduction
2.0 Objectives
3.0 Main Content
3.1 Quadtrees
3.2K-d-trees
3.3 BSP Trees
3.4 Bounding Volume Hierarchies
4.0 Conclusion
5.0 Summary
6.0 Tutor Marked Assignment
1.0Introduction
In recent years, methods from computational geometry have been widely adopted by the
computer graphics community. Many solutions draw their elegance and efficiency from the
mutually enriching combination of such geometrical data structures with computer graphics
algorithms. This course imparts a working knowledge of a number of essential geometric
data structures and explains their elegant use in several representatives, diverse, and
current areas of research in computer graphics such as terrain visualization, texture
synthesis, modelling, and tesselation. Our selection of data structures and algorithms
consists of well-known concepts, which are both powerful and easy to implement, ranging
from quadtrees to BSP trees and bounding volume trees.
2.0 Objectives
The major objective of this unit is to present each geometric data structure, familiarize
students with some very versatile and ubiquitous geometric data structures, enable them to
readily recognize geometric problems during their work, modify the algorithms to their
needs, and hopefully make them familiar with the basic principles of graphics data and the
type of problems in the area.
Quadtrees can store many kinds of data. We will describe the variant that stores a set of
points and suggest a recursive definition. A simple recursive splitting of squares is continued
until there is only one point in a square. Let P be a set of points. The definition of a quadtree
for a set of points in a square Q = [x1Q : x2Q] £ [y1Q : y2Q] is as follows:
• If jPj · 1 then the quadtree is a single leaf where Q and P are stored.
• Otherwise let QNE, QNW, QSW and QSE denote the four quadrants. Let
xmid := (x1Q + x2Q)/2 and
ymid := (y1Q + y2Q)/2, and define
PNE := {p ∈ P : px > xmid ^ py > ymid}
PNW := {p ∈ P : px · xmid ^ py > ymid}
PSW := {p ∈ P : px · xmid ^ py · ymid}
PSE := {p ∈ P : px > xmid ^ py · ymid}
The quadtree consists of a root node v, Q is stored at v. In the following, let Q(v) denote the
square stored at v. Furthermore v has four children: The X-child is the root of the quadtree
of the set PX, where X is an element of the set {NE, NW, SW, SE}.
3.1.1 Uses
Quadtrees are used to partition 2-D space, while octrees are for 3-D. The two concepts are
nearly identical, and I think it is unfortunate that they are given different names.
Handling Observer-Object Interactions:
Subdivide the quadtree/octree until each leaf’s region intersects only a small number of
objects.
Each leaf holds a list of pointers to objects that intersect its region.
Find out which leaf the observer is in. We only need to test for interactions with the objects
pointed to by that leaf.
• Inside/Outside Tests for Odd Shapes
The root node represent a square containing the shape.
If a node’s region lies entirely inside or entirely outside the shape, do not subdivide it.
Otherwise, do subdivide (unless a predefined depth limit has been exceeded).
Then the quadtree or octree contains information allowing us to check quickly whether a
given point is inside the shape.
• Sparse Arrays of Spatially-Organized Data
Store array data in the quadtree or octree.
Only subdivide if that region of space contains interesting data.
This is how an octree is used in the BLUIsculpt program.
3.2 K-d-Trees
The k-d-tree is a natural generalization of the one dimensional search tree.
Let D be a set of n points in k. For convenience let k = 2 and let us assume that all X- and
Y- coordinates are different.
First, we search for a split-value s of the X-coordinates. Then we split D by the split-line X = s
into subsets:
D<s={(x, y)}ϵ D; x <s } = D Ո {X < S}
D>s = ,(x, y) D; x > s- = D ∩ ,X > s-.
For both sets we proceed with the Y-coordinate and split-lines Y = t1 and Y = t2. We repeat
the process recursively with the constructed subsets. Thus, we obtain a binary tree, namely
the 2-tree of the point set D, as shown in the Figure above. Each internal node of the tree
corresponds to a split-line.
For every node v of the 2-d-tree we define the rectangle R(v), which is the intersection of
halfplanes corresponding to the path from the root to v. For the root r, R(r) is the plane
itself; for the sons of r, say left and right, we produce to halfplanes R(left) and R(right) and so
on. The set of rectangles {R(l) : l is a leaf}gives a partition of the plane into rectangles. Every
R(l) has exactly one point of D inside.
This structure supports range queries of axis parallel rectangles. For example, if Q is an axis-
parallel rectangle, the set of sites vϵ D with vϵ
Q can be computed efficiently. We simply have to compute all nodes v with:
R(v) ∩ ≠ □
Additionally we have to test whether the points inside the subtree of v are inside Q.
A Binary Space Partition tree (BSP tree) is a very different way to represent a scene, Nodes
hold facets, the structure of the tree encodes spatial information about the scene. It is useful
for HSR and related applications
3.2.2 Construction
• To construct a BSP tree, we need: A list of facets (with vertices). An “outside” direction for
each.
• Procedure:
Begin with an empty tree. Iterate through the facets, adding a new node to the tree for
each new facet. The first facet goes in the root node. For each subsequent facet, descend
through the tree, going left or right depending on whether the facet lies inside or outside
the facet stored in the relevant node.
• If a facet lies partially inside & partially outside, split it along the plane *line+ of the
facet.
• The facet becomes two “partial” facets. Each inherits its “outside” direction from
the original facet.
• Continue descending through the tree with each partial facet separately.
Finally, the (partial) facet is added to the current tree as a leaf.
3.2.4 Traversing
An important use of BSP trees is to provide a back-to-front (or front-toback) ordering of the
facets in a scene, from the point of view of an observer.
When we say “back-to-front” ordering, we mean that no facet comes before something that
appears directly behind it. This still allows nearby facets to precede those farther away. Key
idea: All the descendants on one side of a facet can come before the facet, which can come
before all descendants on the other side.
• Procedure:
For each facet, determine on which side of it the observer lies. Back-to-front ordering: Do an
in-order traversal of the tree in which the subtree opposite from the observer comes before
the subtree on the same side as the observer.
• Procedure:
For each facet, determine on which side of it the observer lies. Back-to-front ordering: Do an
in-order traversal of the tree in which the subtree opposite from the observer comes before
the subtree on the same side as the observer.
• Our observer is inside 1, outside 2, inside 3a, outside 3b.
Uses
• BSP trees are primarily useful when a back-to-front or front-toback ordering is desired: For
HSR. For translucency through blending.
• Since it can take some time to construct a BSP tree, they are useful primarily for: Static
scenes. Some dynamic objects are acceptable.
• BSP-tree techniques are generally a waste of effort for small scenes. We use them on:
Large, complex scenes.
3.4 Bounding Volume Hierarchies
Like the previous hierarchical data structures, bounding volume hierarchies (BVHs) are
mostly used to prevent performing an operation exhaustively on all objects. Like with
previously discussed hierarchical data structures, one can improve a huge range of
applications and queries using BVHs, such as ray shooting, point location queries, nearest
neighbor search, view frustum and occlusion culling, geographical data bases, and collision
detection (the latter will be discussed in more detail below). Often times, bounding volume
(BV) hierarchies are described as the opposite of spatial partitioning schemes, such as
quadtrees or BSP trees: instead of partitioning space, the idea is to partition the set of
objects recursively until some leaf criterion is met. Here, objects can be anything from points
to complete graphical objects. With BV hierarchies, almost all queries, which can be
implemented with space partitioning schemes, can also be answered, too. Example queries
and operations are ray shooting, frustum culling, occlusion culling, point location, nearest
neighbor, collision detection.
3.4.2 Bottom-up
In this class, we will actually describe two algorithms. Let B be the set of BVs on the top-
most level of the BV hierarchy that has been constructed so far. For each bi 2 B find the
nearest neighbor b0i 2 B; let di be the distance between bi and b0i. Sort B with respect to di.
Then, combine the first k nodes in B under a common father; do the same with the next
k elements from B, etc. This yields a new set B0, and the process is repeated. Note that this
strategy does not necessarily produce BVs with a small “dead space”:
the strategy would choose to combine the left pair (distance = 0), while choosing the right
pair would result in much less dead space. The second strategy is less greedy in that it
computes a tiling for each level. We will describe it first in 2D. Again, let B be the set of BVs
on the top-most level so far constructed, with |B| = n.
4.0 Conclusion
Presented in this unit are two data structures for multi-dimensional data: Quadtrees and kd-
Trees . Quadtrees are better in some cases as they have less overhead for keeping track of
split lines, Have faster arithmetic compared to kd-Trees, especially for graphics
5.0 Summary
The idea of the binary space partition is one with good general applicability. Some variation
of it is used in a number of different structures.
BSP trees
• Split along planes containing facets. Quadtrees & octrees
• Split along pre-defined planes. kd-trees
• Split along planes parallel to coordinate axes, so as to split up the objects nicely.
• Quadtrees are used to partition 2-D space, while octrees are for 3- D.
The two concepts are nearly identical.
Contents
1.0 Introduction
2.0 Objectives
3.0 Main Content
3.1 Color Space
3.2 Light
3.3 The electromagetic spectrum
3.4 The Retina
3.5 Mapping from Reality to Perception
3.6 Colour Matching
3.7 Spectroradiometer
3.8 Complementary Colours
3.9 Dominant Wavelength
3.10 Non-Spectral Colours
3.11 Colour Gamuts
3.12 The RGB Colour Cube
3.13 Colour Printing
3.14 Colour Conversion
3.15 Other Colour Systems
4.0 Conclusion
5.0 Summary
6.0Tutor Assignment
1.0 Introduction:
Our eyes work by focusing light through an elastic lens, onto a patch at the back of our eye
called the retina. The retina contains light sensitive rod and cone cells that are sensitive to
light, and send electrical impulses to our brain that we interpret as a visual stimulus. Given
this biological apparatus, we can simulate the presence of many colours by shining Red,
Green and Blue light into the human eye with carefully chosen intensities. This is the basis
on which all colour display technologies (CRTs, LCDs, TFTs, Plasma, Data projectors) operate.
Inside our machine (TV, Computer, Projector) we represent pixel colours using values for
Red, Green and Blue (RGB triples) and the video hardware uses these values to generate the
appropriate amount of Red, Green and Blue light.
2.0 Objectives:
Upon successful completion of this module students will be able to:
• describe the nature of colour and its numerical description
• Know the basic principles of colour mixing.
The retina has both rods and cones, as shown below. It is the cones which are responsible
for colour perception.
There are three types of cones, referred to either as B, G, and R, or equivalently as S, M, and
L, respectively. Their peak sensitivities are located at approximately 430nm, 560nm, and
610nm for the "average" observer. Animals exist with both fewer and more types of cones.
The photopigments in rods and cones are stimulated by absorbed light, yielding a change in
the cell membrane potential. The different types of cells have different spectral sensitivities:
4.5 Colour
Matching In order to define the perceptual 3D space in a "standard" way, a set of
experiments can (and have been) carried by having observers try and match colour of a
given wavelength, lambda, by mixing three other pure wavelengths, such as R=700nm,
G=546nm, and B=436nm in the following example. Note that the phosphours of colour TVs
and other CRTs do not emit pure red, green, or blue light of a single wavelength, as is the
case for this experiment.
The above scheme can tell us what mix of R,G,B is needed to reproduce the perceptual
equivalent of any wavelength. A problem exists, however, because sometimes the red light
needs to be added to the target before a match can be achieved. This is shown on the graph
by having its intensity, R, take on a negative value.
In order to achieve a representation which uses only positive mixing coefficients, he CIE
("Commission Internationale d'Eclairage") defined three new hypothetical light sources, x, y,
and z, which yield positive matching curves: If we are given a spectrum and wish to find the
corresponding X, Y, and Z quantities, we can do so by integrating the product of the spectral
power and each of the three matching curves over all wavelengths. The weights X,Y,Z form
the three-dimensional CIE XYZ space, as shown below.
Often it is convenient to work in a 2D colour space. This is commonly done by projecting the
3D colour space onto the plane X+Y+Z=1, yielding a CIE chromaticity diagram. The projection
is defined as given below, and produces the following chromaticity diagram:
A few definitions:
4.6 spectroradiometer
A device to measure the spectral energy distribution. It can therefore also provide the CIE
xyz tristimulus values. illuminant C A standard for white light that approximates sunlight. It is
defined by a colour temperature of 6774 K.
To produce blue, one would mix cyan and magenta inks, as they both reflect blue while each
absorbing one of green and red. Unfortunately, inks also interact in non-linear ways. This
makes the process of converting a given monitor colour to an equivalent printer colour a
challenging problem.
Black ink is used to ensure that a high quality black can always be printed, and is often
referred to as to K. Printers thus use a CMYK colour model.
3.13 Colour Conversion
Monitors are not all manufactured with identical phosphours. To convert from one colour
gamut to another is a relatively simple procedure (with the exception of a few complicating
factors!). Each phosphour colour can be represented by a combination of the CIE XYZ
primaries, yielding the following transformation from RGB to CIE XYZ:
5.0 Conclusion
Colour is one of the most important features in a visual presentation. The perceived colour
of an object is influenced by the colour of the surroundings referred to as colour interaction,
colour induction, or colour assimilation.
6.0 Summary
Color is an immensely complex subject, one that draws on concepts and results from physics,
physiology, psychology, art, and graphic design. Perceived color depends on:
• Object color
• Color of lights illuminating the object
• Color of surrounding objects
• Human visual system
• Object’s absorptive, reflective, emissive, and transmissive properties
Table of Contents
1.0 Introduction
2.0 Objectives
3.0 The Digital Image
3.1 Raster Image Representation
3.2 Hardware Frame Buffers
4.0 Conclusion
5.0 Summary
6.0 Tutor Marked Assignment
1.0 Introduction:
Computer Graphics is principally concerned with the generation of images, with wide
ranging applications from entertainment to scientific visualization. In this unit, we begin our
exploration of Computer Graphics by introducing the fundamental data structures used to
represent images on modern computers. We describe the various formats for storing and
working with image data, and for representing colour on modern machines.
2.0 Objectives:
The main objective is to study how digital images are represented in a computer. This unit
also explores different forms of frame-buffer for storing images, and also different ways of
representing colour and key issues that arise in colour.
3.0 The Digital Image
Virtually all computing devices in use today are digital; data is represented in a discrete form
using patterns of binary digits (bits) that can encode numbers within finite ranges and with
limited precision. By contrast, the images we perceive in our environment are analogue.
They are formed by complex interactions between light and physical objects, resulting in
continuous variations in light wavelength and intensity. Some of this light is reflected in to
the retina of the eye, where cells convert light into nerve impulses that we interpret as a
visual stimulus. Suppose we wish to ‘capture’ an image and represent it on a computer e.g.
with a scanner or camera (the machine equivalent of an eye). Since we do not have infinite
storage (bits), it follows that we must convert that analogue signal into a more limited digital
form. We call this conversion process sampling. Sampling theory is an important part of
Computer Graphics, underpinning the theory behind both image capture and manipulation.
Rasters are used to represent digital images. Modern displays use a rectangular raster,
comprised of W × H pixels. The raster illustrated here contains a greyscale image; its contents
are represented in memory by a greyscale frame buffer. The values stored in the frame buffer
record the intensities of the pixels on a discrete scale (0=black, 255=white).
The pixel is the atomic unit of the image; it is coloured uniformly, its single colour represents
a discrete sample of light e.g. from a captured image.
In most implementations, rasters take the form of a rectilinear grid often containing many
thousands of pixels. The raster provides an orthogonal two-dimensional basis with which to
specify pixel coordinates. By convention, pixels coordinates are zero-indexed and so the
origin is located at the top-left of the image. Therefore pixel (W − 1, H − 1) is located at the
bottom-right corner of a raster of width W pixels and height H pixels. As a note, some
Graphics applications make use of hexagonal pixels instead 1, however we will not consider
these on the course.
The number of pixels in an image is referred to as the image’s resolution. Modern desktop
displays are capable of visualizing images with resolutions around 1024 × 768 pixels (i.e. a
million pixels or one mega-pixel). Even inexpensive modern cameras and scanners are now
capable of capturing images at resolutions of several mega-pixels. In general, the greater the
resolution, the greater the level of spatial detail an image can represent.
Note that the term ‘frame buffer’ as originally defined, strictly refers to the area of memory
reserved for direct manipulation of the currently displayed image. In the early days of
Graphics, special hardware was needed to store enough data to represent just that single
image. However we may now manipulate hundreds of images in memory simultaneously
and the term ‘frame buffer’ has fallen into informal use to describe any piece of storage that
represents an image.
There are a number of popular formats (i.e. ways of encoding pixels) within a frame buffer.
This is partly because each format has its own advantages, and partly for reasons of
backward compatibility with older systems (especially on the PC). Often video hardware can
be switched between different video modes, each of which encodes the frame bufferin a
different way. We will describe three common frame buffer formats in the subsequent
sections; the greyscale, pseudo-colour, and true-colour formats. If you do Graphics, Vision or
mainstream Windows GUI programming then you will likely encounter all three in your work
at some stage.
The frame buffer is arranged so that the first byte of memory corresponds to the pixel at
coordinates (0, 0). Recall that this is the topleft corner of the image. Addressing then
proceeds in a left-right, then top-down manner (see Figure). So, the value (grey level) of
pixel (1, 0) is stored in the second byte of memory, pixel (0, 1) is stored in the (W + 1)th byte,
and so on. Pixel (x, y) would be stored at buffer offset A where:
A = x +Wy (2.1) i.e. A bytes from the start of the frame buffer. Sometimes we use the term
scan line to refer to a full row of pixels. A scan-line is therefore W pixels wide. Old machines,
such as the ZX Spectrum, required more CPU time to iterate through each location in the
frame buffer than it took for the video hardware to refresh the screen. In an animation, this
would cause undesirable flicker due to partially drawn frames. To compensate, byte range
*0, (W − 1)+ in the buffer wrote to the first scan-line, as usual. However bytes *2W, (3W −1)+
wrote to a scan-line one third of the way down the display, and *3W, (4W −1)+ to a scan-line
two thirds down. This interleaving did complicate Graphics programming, but prevented
visual artifacts that would otherwise occur due to slow memory access speeds.
The colours themselves are stored in a “Colour Lookup Table” (CLUT) which is essentially a
map < colourindex, colour > i.e. a table indexed with an integer key (0−255) storing a value
that represents colour. In alternative terminology the CLUT is sometimes called a palette. As
wewill discuss in greater detail shortly, many common colours can be produced by adding
together (mixing) varying quantities of Red, Green and Blue light.
For example, Red and Green light mix to produce Yellow light. Therefore the value stored in
the CLUT for each colour is a triple (R, G,B) denoting the quantity (intensity) of Red, Green
and Blue light in the mix. Each element of the triple is 8 bit i.e. has range (0 − 255) in
common implementations.
The earliest colour displays employed pseudo-colour frame buffers. This is because memory
was expensive and colour images could be represented at identical cost to grayscale images
(plus a small storage overhead for the CLUT). The obvious disadvantage of a pseudocolour
frame buffer is that only a limited number of colours may be displayed at any one time (i.e.
256 colours). However the colour range (we say gamut) of the display is 28 × 28 × 28 = 224 =
16, 777, 216 colours. Pseudo-colour frame buffers can still be found in many common
platforms e.g. both MS and X Windows (for convenience, backward compatibility etc.) and in
resource constrained computing domains (e.g. low-spec games consoles, mobiles). Some
low-budget (in terms of CPU cycles) animation effects can be produced using pseudo-colour
frame buffers. Consider an image filled with an expanses of colour index 1 (we might set
CLUT < 1,Blue >, to create a blue ocean). We could sprinkle consecutive runs of pixels with
index ‘2,3,4,5’ sporadically throughout the image. The CLUT could be set to increasing,
lighter shades of Blue at those indices. This might give the appearance of waves. The colour
values in the CLUT at indices 2,3,4,5 could be rotated successively, so changing the displayed
colours and causing the waves to animate/ripple (but without the CPU overhead of writing
to multiple locations in the frame buffer). Effects like this were regularly used in many ’80s
and early ’90s computer games, where computational expense prohibited updating the
frame buffer directly for incidental animations.
4.0 Conclusion
Image generation remains an integral part of computer graphics hence how these digital
images are represented in a computer cannot be overemphasized in this subject area.
5.0 Summary
In this unit, we have learnt
v. What digital image is.
vi. The concept of Raster Image Representation
vii. About the three common frame buffer format