Scan Conversion Algorithms-2
Scan Conversion Algorithms-2
Scan
Conversion Definition
Line Algorithms
Slope-Intercept Method
Bresenhams
DDA
Circle
Drawing Algorithms
Ellipse Drawing Algorithm
Area Filling Techniques
Character Generation
Copyright @ www.bcanotes.com
SCAN CONVERSION
Copyright @ www.bcanotes.com
P2(x2,y2)
P1(x1,y1)
x
Defining a Line
Copyright @ www.bcanotes.com
Representation of a line
Copyright @ www.bcanotes.com
Copyright @ www.bcanotes.com
Simple Line
Based on the simple slope-intercept algorithm from algebra
y=mx+b
Copyright @ www.bcanotes.com
AN ALGORITHM
0O TO 45O )
1.
Compute
2.
3.
4.
5.
6.
Go to step 4
Copyright @ www.bcanotes.com
dx = x2-x1
dy = y2-y1
m = dy/dx
b = y1-m*x1
Copyright @ www.bcanotes.com
DDA
Incremental scan-conversion method
Faster than the direct use of the line equation
However, a floating point operation is still
required
The line drifts away from the original line when
the line is relatively long.
Copyright @ www.bcanotes.com
AN ALGORITHM
DDA
METHOD
1.
Compute
dx = x2-x1
2.
4
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
Copyright @ www.bcanotes.com
3.
dy = y2-y1
Copyright @ www.bcanotes.com
2.
AN ALGORITHM
0O TO 45O )
1.
4.
5.
6.
7.
8.
9.
10.
(SLOPE
IS BETWEEN
dy = y2-y1
Inc2 = 2 * dy
Copyright @ www.bcanotes.com
3.
METHOD
Compute
dx = x2-x1
inc1 = 2(dy-dx)
d = inc1 - dx
2.
BRESENHAMS
Predominant
distance
Coord. which
changes at each
step
Coord. which
may or may not
change
0< m< 1
m=1
x or y
x and y
1<m<
0 > m> -1
m = -1
x or y
x and y
-1 > m >
Copyright @ www.bcanotes.com
(x,y) (7,2)
(-x,y) (-7,2)
-1
-2
-4
-5
-6
-7
(x,-y) (7,-2)
-3
(-x,-y) (-7,-2)
(y,-x) (2,-7)
Copyright @ www.bcanotes.com
(-y,x) (-2,7)
(y,x) (2,7)
1.
3.
4.
5.
6.
Plot (- x + h, - y + k)
Plot ( - y + h, - x + k)
Plot (y + h, - x + k)
Plot ( x + h, - y + k)
Copyright @ www.bcanotes.com
2.
ELLIPSE
(X/2, Y/2)
Copyright @ www.bcanotes.com
(-X/2, Y/2)
(-X/2, -Y/2)
(X/2, -Y/2)
REGION FILLING
Process
Pixel Level
Boundary defined
Algorithms are referred as Boundary Fill Algorithms
Interior Defined Region
Algorithms are referred as flood-fill Algorithms
Geometric Level
Copyright @ www.bcanotes.com
region
Regions may be defined at
Copyright @ www.bcanotes.com
Algorithm
Begins with a initial pixel inside the region
The Algorithm checks to see if this pixel is a
boundary pixel or has already been filled.
If No, It Fills the pixel and makes a recursive
call to itself using each and every neighboring
pixel as a new seed.
If Yes, the algorithm simply return to its
caller
Copyright @ www.bcanotes.com
Bitmap
Font or Raster
Vector or Outline Font
Copyright @ www.bcanotes.com
Copyright @ www.bcanotes.com