0% found this document useful (0 votes)
56 views

Lecture 03 - Scan Conversion

The document discusses scan conversion and line drawing algorithms. It describes scan conversion as the process of representing graphics objects as a collection of pixels. Two common line drawing algorithms are presented: (1) the Digital Differential Analyzer (DDA) algorithm which calculates pixel positions along a line incrementally based on the slope, and (2) Bresenham's line algorithm. Examples are given to demonstrate how the DDA algorithm works for lines with different slopes.

Uploaded by

devzani nipa
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

Lecture 03 - Scan Conversion

The document discusses scan conversion and line drawing algorithms. It describes scan conversion as the process of representing graphics objects as a collection of pixels. Two common line drawing algorithms are presented: (1) the Digital Differential Analyzer (DDA) algorithm which calculates pixel positions along a line incrementally based on the slope, and (2) Bresenham's line algorithm. Examples are given to demonstrate how the DDA algorithm works for lines with different slopes.

Uploaded by

devzani nipa
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

Computer Graphics

Lecture 03- Scan Conversion


Lecture Outlines
• Scan Conversion
• Point
• Line
• Line Drawing Algorithms
• Direct use of Line Equation
• DDA Algorithm
Rasterization (Scan
Conversion)
• It is a process of representing graphics objects a collection of pixels.
The graphics objects are continuous. The pixels used are discrete.
Each pixel can have either on or off state.
• Two ways to create an image:
• Scan existing photograph
• Procedurally compute values (rendering)

Viewport
Rasterization
Transformation
Rasterization

• A fundamental computer graphics function


• Determine the pixels’ colors, illuminations, textures, etc.
• Implemented by graphics hardware
• Rasterization algorithms
• Lines

• Circles

• Triangles

• Polygons
Scan Converting a point
Each pixel on the graphics display does not represent a
mathematical point. Instead, it means a region which
theoretically can contain an infinite number of points. Scan-
Converting a point involves illuminating the pixel that contains
the point.

• (x,y) where x and y are real numbers within an image area.


• Need to be scan converted at pixel location
Scan Converting a Point

(4.3,3.3)
Scan Converting a line
Line drawing is accomplished by calculating intermediate
positions along the line path between two specified end points.
Scan Convert a Vertical/Horizontal
Line
Line 1: (0,0),(4,0)
Line 2: (4,0),(4,4)

(0,0) 4
Basic Line
Algorithms
• Lines must create visually satisfactory images.
• Lines should appear straight
• Lines should terminate accurately
• Lines should have constant density
• Line density should be independent of line length and angle.
• Lines sharing vertex should avoid/minimize overlap
• Lines sharing vertex should avoid/minimize gaps!
• Line algorithm should always be defined.
Line Drawing Algorithm

8
7 Line: (3,2) -> (9,6)
6
5
4
? Which intermediate
pixels to turn on?
3
2
1

0 1 2 3 4 5 6 7 8 9 10 11 12
Direct use of the Line equation

• Slope-intercept line equation


• y = mx + c
• Given two end points (x0,y0), (x1, y1), how to compute m and c?

(x1,y1)
dy

(x0,y0)
dx
Line Drawing Algorithm

• DDA Algorithm
• Bresenham’s Line Algorithm
DDA Algorithm
• Digital Differential Analyzer is an algorithm for scan-
converting lines
• It calculates pixel positions along a line by taking
unit step increment along one direction and
calculating corresponding coordinate position based
on the rate of change of the coordinate
DDA Algorithm
 Given two end points (,), (,)

 𝑚= 𝑦 2 − 𝑦 1
𝑥 2 − 𝑥1

 
(,)

 
(,)
 
(,)
DDA Algorithm

Various
Cases
xn = x1 + 1
|m|<1 yn= y1+ m

xn= x1 +
|m|>1 yn= y1 + 1

xn = x1 + 1
|m|=1 yn= y1 + 1
DDA Algorithm
Example

 
two end points
(,), (,)  
(,)

Slope,m =
=  
(,
=
= 1
DDA Algorithm
two end points (,), (,)
 
As m=1,
x n = x1 + 1
 
(,)
yn = y1 + 1

x1 y1 xn yn
2 4 2+1=3 4+1=5  
(,)

 
(,
DDA Algorithm
As m=1,
xn = x 1 + 1
yn= y1 + 1  
(,)

 
(,)
x1 y1 xn yn  
(,)
2 4 2+1=3 4+1=5  
(,

3 5 3+1=4 5+1=6
DDA Algorithm
As m=1,
xn = x 1 + 1
yn= y1 + 1  
(,)

 
(,)

 
(,)
x1 y1 xn yn  
(,)

2 4 2+1=3 4+1=5  
(,

3 5 3+1=4 5+1=6

4 6 4+1=5 6+1=7
DDA ALGORITHM
As m=1,
xn = x 1 + 1
yn= y1 + 1  
(,)

 
(,)
x1 y1 xn yn  
(,)
2 4 2+1=3 4+1=5  
(,)
 
(,)
3 5 3+1=4 5+1=6
 
(,
4 6 4+1=5 6+1=7

5 7 5+1=6 7+1=8
DDA Algorithm
As m=1,
xn = x 1 + 1
yn= y1 + 1  
(,)

 
(,)
x1 y1 xn yn  
(,)
2 4 2+1=3 4+1=5  
(,)
 
(,)
3 5 3+1=4 5+1=6
 
(,
4 6 4+1=5 6+1=7

5 7 5+1=6 7+1=8

6 8 6+1=7 8+1=9
DDA Algorithm
 
Slope,m = = = = 0.57 ≈ 0.6 Consider endpoints:
(0,0), (7,4)
As m<1,
xn = x1 + 1
yn= y1+ m
x1 y1 xn yn
0 0 0+1=1 (6,4) (7,4)
0+.6=.6 ≈1
1 1 1+1=2 .6+.6=1.2 ≈ 1 (4,2) (5,3)
2 1 2+1=3 1.2+.6=1.8 ≈ 2 (2,1)
(3,2)
(1,1)
3 2 3+1=4 1.8+.6=2.4 ≈ 2
(0,0)
4 2 4+1=5 2.4+.6 = 3
5 3 5+1=6 3+.6=3.6 ≈ 4
6 4 6+1=7 3.6+.6=4.2 ≈ 4
Thank You

You might also like