Computer Graphics
Computer Graphics
9. The '00's
Today most graphicist want an Intel PC with at least 256 MB of memory and a 10 GB hard
drive. Their display should have graphics board that supports real-time texture mapping. A flatbed
scanner, color laser printer, digital video camera, DVD, and MPEG encoder/decoder are the
peripherals one wants. The environment for program development is most likely Windows and
Linux, with Direct 3D and OpenGL, but Java 3D might become more important. Programs would
typically be written in C++ or Java.
What will happen in the near future -- difficult to say, but high definition TV (HDTV) is poised to
take off (after years of hype). Ubiquitous, untethered, wireless computing should become
widespread, and audio and gestural input devices should replace some of the functionality of the
keyboard and mouse.
You should expect 3-D modeling and video editing for the masses, computer vision for
robotic devices and capture facial expressions, and realistic rendering of difficult things like a human
face, hair, and water.
ETHICAL ISSUES
Graphics has had a tremendous effect on society. Things that affect society often lead to ethical and
legal issues. For example, graphics are used in battles and their simulation, medical diagnosis, crime
re- enactment, cartoons and films. The ethical role played by a computer graphic is in the use of
graphics programs that may be used for these and other purposes is discussed and analyzed in the
notes on Ethics.
2. Scientific Visualization
Computer graphics makes vast quantities of data accessible. Numerical simulations frequently
produce millions of data values. Similarly, satellite-based sensors amass data at rates beyond our
abilities to interpret them by any other means than visually. Mathematicians use computer graphics
to explore abstract and high-dimensional functions and spaces. Physicists can use computer graphics
to transcend the limits of scale. With it they can explore both microscopic and macroscopic world
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 state- of-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.
8
GRAPHICS HARDWARE, SOFTWARE AND DISPLAY DEVICES
GRAPHICS SOFTWARE
Graphics software (that is, the software tool needed to create graphics applications) has taken the
form of subprogram libraries. The libraries contain functions to do things like: draw points, lines,
polygons apply transformations fill areas with color handle user interactions. An important goal has
been the development of standard hardware- independent libraries such as:
CORE GKS (Graphical Kernel Standard)
PHIGS (Programmer’s Hierarchical Interactive Graphics System)
X Windows OpenGL
GRAPHICS HARDWARE
DISPLAY HARDWARE
An important component is the “refresh buffer” or “frame buffer” which is a random-access
memory containing one or more values per pixel, used to drive the display.
The video controller translates the contents of the frame buffer into signals used by the CRT to
illuminate the screen. It works as follows:
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
4. 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.
FLAT-PANEL DISPLAYS:
This is the Technology used to replace CRT monitors.
Characterized by Reduced volume, weight, power needs
Thinner: can hang on a wall
Higher resolution (High Definition).
And comes in Two categories: Emissive and Non-Emissive
Other technologies require storage of x-y coordinates of pixels, e.g.: Thin-film electroluminescent
displays, LEDs, Flat CRTs.
Non-Emissive Flat Panel Display Devices:
Use optical effects to convert ambient light to pixel patterns,
Example: LCDs
Pass polarized light from surroundings through liquid crystal material that can be aligned to
block or transmit the light
Voltage applied to 2 intersecting conductors determines whether the liquid crystal blocks
or transmits the light
Like emissive devices, require storage of x-y coordinates of pixel to be illuminated
VECTOR SCAN SYSTEMS
Also called random, stroke, calligraphic displays, it possesses the following features:
i. Its images are drawn as line segments (vectors)
ii. Beam can be moved to any position on screen
iii. Refresh Buffer stores plotting commands so Frame Buffer often called "Display File”
provides DPU with needed endpoint coordinates. Its pixel size is independent of frame buffer which
gives a very high resolution
“Vector graphics” i.e. Early graphic devices were line-oriented. For example, a “pen plotter”
from H-P. Image stored as line segments (vectors) that can be drawn anywhere on display device
Primitive operation is line drawing.
Advantages of Vector Scan
High resolution (good for detailed line drawings)
Crisp lines (no "jaggies")
High contrast (beam can dwell on a single point for some time ==> very bright)
Selective erase (remove commands from display file)
Animation (change line endpoints slightly after each refresh)
Disadvantages of Vector Scan
Complex drawings can have flicker Many lines so if time to draw > refresh time ==> flicker
High cost--very fast deflection system needed
Hard to get colors
No area fill: so it’s difficult to use for realistic (shaded) images
1960s Technology, only used for special purpose stuff today
RASTER SCAN SYSTEMS (TV Technology)
Beam continually traces a raster pattern. Its Intensity is adjusted as raster scan takes place
• In synchronization with beam
• Beam focuses on each pixel
• Each pixel’s intensity is stored in frame buffer
• So resolution determined by size of frame buffer
Each pixel on screen visited during each scan, and Scan rate must be >= 30 Hz to avoid flicker
“Raster graphics” is today’s standard. A raster is a 2-dimensional grid of pixels (picture elements). Image
stored as a 2D array of color values in a memory area called the frame buffer. Each value stored determines
the color/intensity of an accessible point on display device
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: Laser printer, Ink-jet printer, Film recorder, Electrostatic printer, Pen
plotter.
Scan Conversion here refers to the Process of determining which pixels need to be turned on in the
frame buffer to draw a given graphics primitive. It needs algorithms to efficiently scan convert
graphics primitives like lines, circles, etc.
TYPES OF CRT
1. Direct View Storage Tubes (not CRT, no need for refresh, pictures stored as a permanent
charge on phosphor screen)
2. Calligraphic refresh CRT (line drawing or vector random scan, need refreshing)
3. Rasterscan (point by point refreshing)
Refresh rate: # of complete images (frames) drawn on the screen in 1 second. Frames/sec.
Frame time: reciprocal of the refresh rate, time between each complete scan. sec/frame
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.)
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.
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.
Resolution
A display’s “resolution” is determined by:
i. number of scan lines (Each left-to-right trace)
ii. number of pixels (Each spot on the screen) per scan line
iii. number of bits per pixel
Resolution is used here to mean total number of bits in a display. It should really refer to the
resolvable dots per unit length.
Examples:
Bitmapped display: 960 x 1152 x 1b 1/8 M B
NTSC TV: 640 x 480 x 1 6b 1/2 M B
Color workstation: 1280 x 1024 x 24b 4 MB
Laser-printed page:
300 dpi: 8.5 x 11 x 300 x 1b 1 MB
1200 dpi: 8.5 x 11 x 1200 x 1b 17 MB
Film: 4500 x 3000 x 30b 50 MB
Frame aspect ratio = horizontal / vertical size
TV 4:3
HDTV 16 : 9
Letter-size paper 8.5 : 11 (about 3 : 4)
35mm film 3:2
Panavision 2.35 : 1
Pixel aspect ratio = pixel width / pixel height (nowadays, this is almost always 1.)
Hardware Frame Buffers
We represent an image by storing values for the colour of each pixel in a structured way. Since the
earliest computer Visual Display Units (VDUs) of the 1960s, it has become common practice to
reserve a large, contiguous block of memory specifically to manipulate the image currently shown
on the computer’s display. This piece of memory is referred to as a frame buffer. By reading or
writing to this region of memory, we can read or write the colour values of pixels at particular
positions on the display.
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 buffer in a different
way.
Three common frame buffer formats will be discuss 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.
There are many ways for creating graphical data. The Classic way is Geometric Modeling.
Other approaches are:
3D scanners
Photography for measuring optical properties
Simulations, e.g., for flow data
Geometric Modeling is the computer-aided design and manipulation of geometric objects. (CAD).
It is the basis for:
Computation of geometric properties
Rendering of geometric objects
Physics computations (if some physical attributes are given)
Geometric objects convey a part of the real or theoretical world; often, something tangible. They are
described by their geometric and topological properties:
Geometry describes the form and the position/orientation in a coordinate system.
Topology defines the fundamental structure that is invariant against continuous
transformations.
23
3D models are geometric representations of 3D objects with a certain level of abstraction. Let’s
distinguish between three types of models:
1) Wire Frame Models: describe an object using boundary lines. No relationship exist between
these curves and surfaces between them are not defined
3) Solid Models: describe an object as a solid, that is, it describe the 3D object completely by
covering the solid
Properties of Surface models:
i. For every point in 3D, we can decide whether it is inside or outside of the solid.
ii. Visibility and intersection computations are fully supported
iii. Basis for creating solid objects using computer-aided manufacturing
A Cartesian coordinate system is an orthogonal coordinate system with lines as coordinate axes.
A Cartesian coordinate frame is a Cartesian coordinate system positioned in space.
Right/Left-handed coordinate system
Vectors
A vector u; v;w is a directed line segment (no concept of position). Vectors are represented in a
coordinate system by a n-tuple v = (v1; : : : ; vn).
The dimension of a vector is dim(v) = n.
Length jvj and direction of a vector is invariant with respect to choice of Coordinate system.
Matrix Algebra
A matrix is a rectangular array of numbers. Both vectors and scalars are degenerate forms of
matrices. By convention we say that an (n×m) matrix has n rows and m columns; i.e. we write
(height × width). In this subsection we will use two 2 × 2 matrices for our examples:
Observe that the notation for addressing an individual element of a matrix is x row, column.
Matrix Addition
Matrices can be added, if they are of the same size. This is achieved by summing the elements in
one matrix with corresponding elements in the other matrix:
This is identical to vector addition.
Matrix Scaling
Matrices can also be scaled by multiplying each element in the matrix by a scale factor.
Again, this is identical to vector scaling.
Matrix Multiplication
As we will see later, matrix multiplication is a cornerstone of many useful geometric transformations
in Computer Graphics. You should ensure that you are familiar with this operation.
In general each element cij of the matrix C = AB, where A is of size (n×P) and B is of size (P
Not all matrices are compatible for multiplication. In the above system, A must have as many
columns as B has rows. Furthermore, matrix multiplication is non-commutative, which means that
BA 6= AB, in general. Given equation 1.27 you might like to write out the multiplication for BA to
satisfy yourself of this.
Finally, matrix multiplication is associative i.e.: ABC = (AB)C = A(BC)
If the matrices being multiplied are of different (but compatible) sizes, then the complexity of
evaluating such an expression varies according to the order of multiplication1.
For some matrices (the orthonormal matrices), the transpose actually gives us the inverse of the
matrix. We decide if a matrix is orthonormal by inspecting the vectors that make up the matrix’s
columns, e.g. [a11, a21]T and [a12, a22]T . These are sometimes called column vectors of the matrix. If
the magnitudes of all these vectors are one, and if the vectors are orthogonal (perpendicular) to each
other, then the matrix is orthonormal. Examples of orthonormal matrices are the identity matrix, and
the rotation matrix that we will meet in subsequent classes.
GRAPHICS RENDERING: TRANSFORMATION
In Computer Graphics we most commonly model objects using points, i.e. locations in 2D or 3D
space. For example, we can model a 2D shape as a polygon whose vertices are points. By
manipulating the points, we can define the shape of an object, or move it around in space.
In 3D too, we can model a shape using points. Points might define the locations (perhaps the
corners) of surfaces in space. In this unit, we will describe how to manipulate models of objects
and display them on the screen.
Transformation
Transformations are often considered to be one of the hardest concepts in elementary computer
graphics. But transformations are straightforward, as long as you
• Have a clear representation of the geometry
• Understand the underlying mathematics
• Are systematic about concatenating transformations
Given a point cloud, polygon, or sampled parametric curve, we can use transformations for
several purposes:
1. Change coordinate frames (world, window, viewport, device, etc).
2. Compose objects of simple parts with local scale/position/orientation of one part defined with
regard to other parts. For example, for articulated objects.
3. Use deformation to create new shapes.
A. TRANSLATION (2D)
This is a transformation on an object that simply moves it to a different position somewhere else
within the same coordinate system. To translate an object, we translate each of its vertices (points). It
involves moving an object along a line from one location to another.
To translate the point (x1 , y1) by tx in x and ty in y
– result is (x2, y2) So, (x2, y2) = (x1 + tx, y1 + ty)
• Translations can be represented by adding vectors.
[ x1 ] + [ tx ] = [ x1 + tx ]
[ y1 ] [ ty ] [ y1 + ty ]
Suppose we want to move a point from A to B e.g, the vertex of a polygon. This operation is
called a translation
To translate point A by (tx, ty), we add (tx, ty) to A’s coordinates
x’ = x + tx y’ = y + ty
B. Rotation (2D)
Rotation is a transformation on an object that changes its position by rotating the object some angle
about some axis. Rotations in the x-y plane are about an axis parallel to z. The point of intersection
of the rotation axis with the x-y plane is the pivot point. We need to specify the angle and pivot
point about which the object is to be rotated.
• To rotate an object, we rotate each of its vertices (points).
• Positive angles are in the counterclockwise direction.
*Rotate (x1 , y1) by some angle B counterclockwise, the result is (x2, y2)
(x2, y2) = (x1 * cos(B) – y1 * sin(B), y1 * cos(B) + x1 * sin(B))