Computer Graphics: Comp Sci 3GC3 Winter 2010
Computer Graphics: Comp Sci 3GC3 Winter 2010
3
Image Processing
Manipulating images to:
Improve quality
Detect lines/curves
Detect corners
Sharpen/blur
Segment
…
Often used to facilitate computer vision
Computer Imaging
Computer imaging deals with storing,
manipulating, and transforming images with a
computer.
Images need first to have been input by some
means, such as a scanner, a video camera, a
digital camera, etc.
More generally, computer imaging deals with all
aspects of processing images with a computer,
and encompasses image synthesis and analysis.
This class deals with computer graphics – image
synthesis.
5
Course Goals Summary
Emphasis on developing applications
visual feedback: the great motivator
incremental approach
some user interface development
learn OpenGL API
Course Goals
Learn and utilize general principles in
computer graphics
2D and 3D graphics concepts
interactive graphical techniques
how OpenGL provides the graphics
programming tools that implement these
principles
learn how some techniques are
implemented as well as the algorithms
behind the techniques
Course Information
Main Text:
Computer Graphics with OpenGL
Second Edition, Hearn Baker, Prentice Hall,
2004
Supplemental Texts:
Red Book
Course Information
Grading
Project(s) 50%
Mid term 15%
Final Exam: 35%
Development Environment
OpenGL API
C++
Output Primitives
Make up computer generated images
polylines
connected sequence of straight lines
vertices and line (edge) between adjacent vertices
( x0 , y0 ), ( x1 , y1 ), ( x2 , y2 ),...( xn , yn )
pictures composed of polylines are called line
drawings, wireframe
polygon: polyline with the first and last
points connected by a edge
simple polygon: polygon where no two
edges cross
Output Primitives
polylines
simple polygon if no two edges cross
can appear smooth if small line segments are
used
Output Primitives
Polyline attributes:
color
edge thickness
edge pattern
System Bus
I/O devices
1 bit
2 levels
Electron
Gun
3-Bit Color
3
Display
red
green
blue
R 0 1 0 0 1 0 1 1
G 0 0 1 0 1 1 0 1
B 0 0 0 1 0 1 1 1
True Color Display
24 bitplanes, 8 bits
8 per color gun.
242 = 16,777,216
8
8 Red
Green
Blue
Deeper Frame Buffers
Some frame buffers have 96 or more bits per pixel. What are
they all for? We start with 24 bits for RGB.
Alpha channel: an extra 8 bits per pixel, to represent
“transparency.” Used for digital compositing. That’s 32 bits.
A Z-buffer, used to hold a “depth” value for each pixel. Used for
hidden surface 3-D drawing. 16 bits/pixel of “z” brings the total
to 48 bits.
Double buffering:
For clean-looking flicker-free real time animation.
Two full frame buffers (including alpha and z).
Only one at a time is visible—you can toggle instantly.
Draw into the “back buffer” (invisible), then swap.
Can be faked with off-screen bitmaps (slower.)
2 x 48 = 96.
Color Index
Another method of relating pixel values with
color values
Pixel value is an index into a color lookup
table (LUT)
Allows for more colors to be displayed while
keeping the frame buffer size from getting
too big.
Color Map Look-Up
Tables
y RED
max
GREEN
255
BLUE
1
1
0
y 0
0 67 Pixel displayed
0
1 1001 1010 0001
0
67 100110100001 at x', y'
R G B
Pixel in
bit map 0
0 at x', y'
0 x x
max
Application Structure
Configure and open window (GLUT)
Initialize OpenGL state (OpenGL)
Register input callback functions (GLUT)
Render
Resize
void init(void)
{
glClearColor(0,0,0,1);
glEnable(GL_LIGHT0); Don’t worry
glEnable(GL_LIGHTING); what they are
… for now…
}
Sample Program
#include <GL/glut.h>
#include <GL/gl.h>
MainLoop Mouse
Window
…
glutMainLoop(); The program goes into a infinite loop
waiting for events
}
Put it all together
#include <GL/glut.h>
#include <GL/gl.h>