CSC418/2504 Computer Graphics
CSC 418/2504: Computer Graphics
Course web site (includes course information sheet):
https://github.com/dilevin/computer-graphics-csc418
Instructors:
Prof. David I.W. Levin diwlevin@cs.toronto.edu
Gavin Barill gavin.barill@mail.utoronto.ca
Proffice Hours:
Dave – Tuesday 5-6pm, Wednesday 5-6pm
Gavin – TBD
TA Office Hours: TBD
Schedule
Lectures
LEC0101 Wednesdays 15:00-17:00 in BA1190
LEC2001 Wednesdays 15:00-17:00 in BA1100
LEC0201 Tuesdays 15:00-17:00 in BA1170
LEC2201 Tuesdays 15:00-17:00 in BA1170
Tutorials
LEC0101 Monday 15:00-16:00 in BA1190
LEC2001 Monday 15:00-16:00 in BA1190
LEC0201 Monday 15:00-16:00 in BA1210
LEC2201 Monday 15:00-16:00 in BA1210
Required Textbook
(Lots of figures on slides adapted from here)
Schedule (on the webpage)
Academic Honesty Policy
It’s on the webpage and is mandatory reading!
Administrivia
Grading:
% Item
70% Assignments
20% Monday, Feb 25, in-tutorial exam
10% Monday, March 25, in-tutorial exam
Tutorial sessions:
• Math refreshers, tutorials on graphic libraries, additional
topics.
• Attendance STRONGLY encouraged since I will not be
lecturing on these topics in class.
Today
1. Introduction to Computer Graphics
2. Preview of class assignments
3. Raster Images
But First ……
Preliminary Math Quiz
DON’T PANIC IT’S NOT PART OF YOUR GRADE!
Goals:
1. Show you what kind of mathematical background is expected in this
course
2. Show you what you need to brush up on. Questions about these basic
math operations will not be answered by either Professors or TAs, we
expect you to know this stuff.
3. Give you a sense of how ready you are to take this course.
Time: 20 minutes (should be more than enough)
DON’T PANIC IT’S NOT PART OF YOUR GRADE!
Introduction to Computer Graphics
What is Computer Graphics?
Computers:
accept, process, transform and present information.
Computer Graphics:
accept, process, transform and present information
in a visual form.
“Core” Areas of Computer Graphics
Modeling
Rendering
Animation
Modelling
http://www.blenderunleashed.com/tutorials/essential-modeling-skills-basic-operators-part-2/
Rendering
Animation
Other Areas of Computer Graphics
User Interaction
Virtual Reality
Visualization
Image Processing
3D Scanning
Computational Photography
Assignment Previews
Raster Images
Ray Casting
Ray Tracing
Boundary Volume Hierarchies
Meshes
Shaders
Kinematics
Final Project: Image Showcase !
To the terminal …
Raster Images
Raster Displays
Raster Displays
Pixel
Raster Displays
Raster Displays
Raster Input Devices
Raster Input Devices
Raster Input Devices
Bayer Filter
Raster Input Devices
Raster Image
Aside: More Than Just Raster Images
Images as a Function
<latexit sha1_base64="(null)">(null)</latexit>
Image coordinates ????
Images as a Function
nD Real Numbers > 0
<latexit sha1_base64="(null)">(null)</latexit>
Image coordinates 2D Real Numbers
Images as a Function
<latexit sha1_base64="(null)">(null)</latexit>
A Pixel is not a Square
Object Image
A Pixel is not a Square
Object Image
A Pixel is not a Square
<latexit sha1_base64="(null)">(null)</latexit>
Object Image
Standard Pixel Coordinate System
Data Types for Raster Images
Storage for 1024x1024 image (1 megapixel)
bitmap: 128KB
grayscale 8bpp: 1MB
grayscale 16bpp: 2MB
color 24bpp: 3MB
floating-point HDR color: 12MB
RGB Images
Artifacts of Raster Images: Banding
Artifacts of Raster Images: Clipping
Original Clipped
Gamma Correction
Display intensity is nonlinear wrt input intensity
Gamma Correction
Gamma Correction
Gamma
… of display Amplitude from Image [0,1]
Gamma Correction
Measure: Find image amplitude that = ½ display brightness
Fit model
Gamma Correction
Transparency
Append (Red, Green, Blue) to be (Red, Green, Blue, Alpha)
without
and
with
alpha
Transparency
Append (Red, Green, Blue) to be (Red, Green, Blue, Alpha)
without
and
with
alpha
Compositing
Compositing is about layering images on top of one another
http://ssp.impulsetrain.com/porterduff.html
Compositing
Compositing is about layering images on top of one another
http://ssp.impulsetrain.com/porterduff.html
Compositing
Compositing is about layering images on top of one another
http://ssp.impulsetrain.com/porterduff.html
Compositing
Compositing is about layering images on top of one another
http://ssp.impulsetrain.com/porterduff.html
Compositing
Compositing is about layering images on top of one another
http://ssp.impulsetrain.com/porterduff.html
Compositing
Compositing is about layering images on top of one another
http://ssp.impulsetrain.com/porterduff.html
Assignment 1 Available Right Now
DUE IN TWO WEEKS (START EARLY!)
Next Week: Ray Casting
What is an Image?
Image = distribution of light energy on 2D
“film”
Digital images represented as rectangular
arrays of pixels
Raster Devices
Input (scanners, cameras)
2D array sensor: digital camera
Output (printers, displays)
Emissive: light-emitting diode (LED)
Transmissive: liquid crystal display
(LCD)
Camera Sensor Array
Bayer color mosaic
[Foveon]
Raster image representation
All these devices suggest 2D arrays of numbers
Bitmaps: boolean per pixel (1 bpp):
• interp. = black and white; e.g. fax
Grayscale: integer per pixel:
• interp. = shades of gray; e.g. black-and-white print
• precision: usually byte (8 bpp); sometimes 10, 12, or 16 bpp
Color: 3 integers per pixel:
• interp. = full range of displayable color; e.g. color print
• precision: usually byte[3] (24 bpp)
• sometimes 16 (5+6+5) or 30 or 36 or 48 bpp
Floating point:
[Philip Greenspun]
• more abstract, because no output device has infinite range
• provides high dynamic range (HDR)
• represent real scenes independent of display
• becoming the standard intermediate format in graphics processor
Datatypes for raster images
• Transparency (add alpha channel)
without
and
with
alpha
• Storage for 1024x1024 image (1 megapixel)
• bitmap: 128KB
• grayscale 8bpp: 1MB
• grayscale 16bpp: 2MB
• color 24bpp: 3MB
• floating-point HDR color: 12MB
Converting pixel formats COLOR
Color to gray
• could take one channel (blue, say)
leads to odd choices of gray value
• combination of channels is better
BLUE ONLY
but different colors contribute
differently to lightness
which is lighter, full blue or full green?
good choice: gray = 0.2 R + 0.7 G + 0.1 B GRAY
Same luminance?
Converting pixel precision
Up is easy, down loses information…
[photo: Philip Greenspun]
8 7bpp
bpp (256
(128grays)
grays)
6 5bpp
bpp(64
(32grays)
grays)
4 bpp
3 bpp (8grays)
(16 grays)
Dithering
Decreasing bpp => quantize/threshold
• Consistent quantization causes banding.
• Trade spatial for tonal resolution: Dither.
Ordered: regular grid of compact dots Diffusion: scattered dots matching local density
Gamma correction
~0.0 ~0.00
0.1 0.01
0.2 0.04
0.3 0.09
0.4 0.16
0.5 0.25
0.6 0.36
0.7 0.49
0.8 0.64
0.9 0.81
1.0 1.00
Topic 3.
Scan Conversion
2D Drawing
Common geometric objects:
When drawing a picture, 2D geometric shapes are specified as if
they are drawn on a continuous plane (80,60)
Drawing command:
Draw a line from point (10,5)
y
to point (80,60)
(10,5)
x
2D Drawing
In reality, computer displays are arrays of pixels, not abstract
mathematical continuous planes
Continuous line Digital line
(80,60)
y y
(10,5)
x x
Equation of a Line
Line between (x0,y0) and (x1,y1)
dx= x1 – x0 ,dy=y1 – y0
Explicit : y = mx + b
m=dy/dx, b=y0 -mx0
Parametric :
x(t) = x0 + dx*t
y(t) = y0 + dy*t
P = P0 + (P1-P0)*t
DDA Algorithm
Explicit form:
y= dy/dx * (x-x0) + y0
dx = x1-x0; dy = y1 – y0;
m = dy/dx;
for ( x=0; x<=x1-x0; x++)
{
setpixel (x+x0, round(m*x+y0));
}
Anti-Aliasing
Raster line drawing can make look jaggy!
How can we make a digital line appear less
jaggy?
Aliased line Anti-aliased line
Intensity proportional to pixel
area covered by “thick” line
Rasterization or Scan Conversion of triangles
Rasterize horizontal span of pixels between a pair of triangle edges.
73
Image making algorithms
Object-Order
for-each object
update the pixels the object
influences;
Image-Order
for-each pixel
set the pixel based on the objects