{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Rasterization

# Rasterization - Computer Graphics Page 1 Rasterization...

This preview shows pages 1–8. Sign up to view the full content.

Computer Graphics Page 1 Rasterization Overview Raster Display Device Scan Conversion / Rasterization: converting vector graphics into raster graphics (determining pixels in raster graphics to represent primitives in vector graphics). 02/23/11 FB Screen Display Controller Application (CGA1.EXE) GDI (SRGP) FB Screen output input scan convert rasterization Keyboard software hardware

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Computer Graphics Page 2 Scan Converting Lines The Basic Incremental Algorithm A line scan-converting algorithm computes the coordinates of the pixels that lie on or near an ideal, infinitely thin straight line imposed on a 2D grid. (Selects pixels on the line to light up.) We need to compute x a , x a+1 , x a+2 , …, x b y a , y a+1 , y a+2 , …, y b dy=y b -y a ; dx=x b -x a ; m = dy /dx; m y y x x b a b a = - - x i, y y m x x i a i a = + - ( ) for i = a, a+1, …, b. 02/23/11 P a (x a ,y a ) P b (x b ,y b ) y y m x x a a = + • - ( )
Computer Graphics Page 3 To increase efficiency, we consider x i+1 : Since pixels are at integer locations, we need round up if m is not an integer: p i (x i , round(y i )), i=a, a+1, a+2, …,b. 02/23/11 y y mx x y m x x y m i a i a a i a i + + +• = +• +- + 1 1 1 ( ) ( ) i a = , x x y y i a i a = = i a = + 1, x x y y m i i i i + + = + = + 1 1 1 Desired line (x i +1,Round(y i +m)) (x i +1, y i +m) (x i , y i ) (x i , Round(y i ))

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Computer Graphics Page 4 DDA (digital differential analyzer): void Line(int x a , int y a , int x b , int y b , int color) { int x; float dy, dx, y, m; dy=y b -y a ; dx=x b -x a ; m=dy/dx; y=y a ; for(x=x a ; x<=x b ; x++) { // light the pixel near (x,y) with the color setPixelColor(x, (int)(y+0.5), color); y += m; } } This code is only good for |m|<=1. Swap x and y when calling the function with |m|>1, and a flag is needed for displaying the swapped case. Drawbacks: accumulating error, FP operation. 02/23/11
Computer Graphics Page 5 Midpoint Line Algorithm Bresenhan Algorithm: Only use integer operation. No accumulation error. Rule: if midpoint below the line, use upper pixel; if it is above use lower pixel. m y y x x b a b a = - - dy = y b – y a dx = x b - x a y y m x x mx y m x dy dx x y dy dx x dy dx x B a a a a a a = +• -= +- •= + -= + ( ) ( ) B = y a – (dy/dx) * x a ; 02/23/11 xdy ydx Bdx - + = 0 ydx xdy Bdx = + M E NE Previous pixel Choices for current pixel Choices for next pixel

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Computer Graphics Page 6 F x y ax by c ( , ) = + + = 0 a dy b dx c Bdx y dy dx x dx a a = = - = = - ( ) Note b < 0 if dx > 0. Decision variable for any given point P(x p ,y p ) is: d(x p ,y p )=a x p + b y p + c. if d=0: P is on the line if d<0: P is above the line if d>0: P is below the line Recursive Midpoint Algorithm 02/23/11 M2
Computer Graphics Page 7 To start the recursion, we need a starting point and the starting decision variable for the next point. We chose P a (x a , y a ) as the starting point and compute d start

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 30

Rasterization - Computer Graphics Page 1 Rasterization...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online