Class Notes (834,933)
CSC418H1 (2)
Lecture

Introduction to Graphics

6 Pages
75 Views

Department
Computer Science
Course
CSC418H1
Professor
Luke Moore
Semester
Fall

Description
CSC418 / CSCD18 / CSC2504 Introduction to Graphics 1 Introduction to Graphics 1.1 Raster Displays The screen is represented by a 2D array of locations called pixels. Zooming in on an image made up of pixels The convention in these notes will follow that of OpenGL, placing the origin in the lower left corner, with that pixel being at location (0,0). Be aware that placing the origin in the upper left is another common convention. One of 2N intensities or colors are associated with each pixel, where N is the number of bits per pixel. Greyscale typically has one byte per pixel, for 2 = 256 intensities. Color often requires one byte per channel, with three color channels per pixel: red, green, and blue. Color data is stored in a frame buffer. This is sometimes called an image map or bitmap. Primitive operations: • setpixel(x, y, color) Sets the pixel at position (x,y) to the given color. • getpixel(x, y) Gets the color at the pixel at position (x,y). Scan conversion is the process of converting basic, low level objects into their corresponding pixel map representations. This is often an approximation to the object, since the frame buffer is a discrete grid. Copyright 2005 David Fleet and Aaron Hertzmann 1 CSC418 / CSCD18 / CSC2504 Introduction to Graphics Scan conversion of a circle 1.2 Basic Line Drawing Set the color of pixels to approximate the appearance of a line from (x ,y )0to0(x ,y ).1 1 It should be • “straight” and pass through the end points. • independent of point order. • uniformly bright, independent of slope. The explicit equation for a line is y = mx + b. Note: Given two points (x ,y0) a0d (x ,y 1 th1t lie on a line, we can solve for m and b for the line. Consider y = mx + b and y = mx + b. 0 0 y −y 1 Subtract y 0rom y to1solve for m = 1 0 and b = y −0mx . 0 x1−x 0 Substitutingin the value for b, this equation can be written as y = m(x − x )+ y .0 0 Copyright 2005 David Fleet and Aaron Hertzmann 2 CSC418 / CSCD18 / CSC2504 Introduction to Graphics Consider this simple line drawing algorithm: int x float m, y m = (y1 - y0) / (x1 - x0) for (x = x0; x <= x1; ++x) { y=m*( x-x )+y0 setpixel(x, round(y), linecolor) } Problems with this algorithm: • If x1 1: (a) m< 1 (b) m> 1 A different number of pixels are on, which implies different brightness between the two. Solution: When m> 1, loop over y = y ...y instead of x, then x = 1(y − y )+ x . 0 1 m 0 0 • Inefﬁcient because of the number of operations and the use of ﬂoating point numbers. Solution: A more advanced algorithm, called Bresenham’s Line Drawing Algorithm. 1.3 Bresenham’s Algorithm Bresenham’s Algorithm is an efﬁcient incremental integer algorithm for line rasterization. It is based on the midpoint rule. Midpoint rule states that if true line at x i+1 is abov
More Less

Related notes for CSC418H1
Me

OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Join to view

OR

By registering, I agree to the Terms and Privacy Policies
Just a few more details

So we can recommend you notes for your school.