0% found this document useful (0 votes)
19 views5 pages

Done L3 Raster Algorithms

Uploaded by

Jay Vora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views5 pages

Done L3 Raster Algorithms

Uploaded by

Jay Vora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

18-08-2024

ME 735
Computer Graphics and Product Modeling Outline

 Display Technology
Raster Graphics Algorithms  Vector Graphics
 Raster Graphics
 Raster Frame Buffer
Prof. S. S. Pande  Raster Graphics Algorithms
Computer Aided Manufacturing Laboratory  DDA Algorithm
Indian Institute of Technology,  Bressenham’s algorithm
Bombay

1 2

Display Technology Display Characteristics


Vector Display
 A Line Drawing Device
 Excellent Picture Quality
 Monochromatic – Calligraphic
Raster Display
 A Point Plotting Device
Vector Raster  Individual Pixel addressability
 Color, Realistic Shading
 Relatively Low Picture Quality
3 4

1 Bit Frame Buffer


Raster Frame Buffer

 Part of memory that Drives Raster


 Array/ Matrix with Integer Values
 Capability to produce colors and grey
levels

Black and White Monitor

1
18-08-2024

3 Bit Frame Buffer RGB Color Frame Buffer

8 Grey Level Monochromatic Display

24 Bit Plane Frame Buffer


Color Wheel
N=8 8 bit Register
8 bit
0 1 --- 0 1 DAC Blue

N=8
8 bit
0 1 --- 0 1 DAC Green

N=8 CRT Raster Display


8 bit
0 1 --- 0 1 DAC Red

Frame Buffer

24 Colors
2

Raster Graphics Algorithms Rasterizing a Line

Rasterization
 Process of Identifying which Pixels
should be made Bright
 Conflicting Criteria
 Need Algorithm to decide

 Implemented in the Device Hardware/


Firmware ? Which Pixels is to be brightened in B?

11

2
18-08-2024

Quality of Rasterized Line Line Drawing Algorithm

Line should Have


 Accurate Start / End
 Good Quality / Fidelity
 Look like a line
 Uniform Brightness along the line
 Good Speed of Drawing

Conflicting Requirements

14

DDA Line Drawing Algorithm DDA Algorithm

To draw line from P1 (x1 , y1) to P2 (x2 , y2)


 Digital Differential Analyzer (DDA)
Principle
 Difference Solution of Differential
Equation
 Incremental Computation of Pixel
addresses

15 16

DDA Algorithm How to choose ∆x, ∆y?

Differential Equation of Line


 Depends on slope of line to be drawn
=m , m = constant slope

=𝑚 m=

 Start Computation with Pi (xi ,yi)  If m ϵ (-1, +1), choose ∆x =1


 Compute Pi+1 (xi+1 , yi+1)
xi+1 = xi + ∆x  Good Fidelity of Line
yi+1 = yi + ∆y

17 18

3
18-08-2024

Incremental Computation DDA Pseudo code

 Compute slope = m
 Choose Increment (∆x, ∆y) based on m
 Choose xT = x1 ,yT = y1
 For ∆x = 1,
 Loop till (xT ≤ x2)
yi+1 = yi + ∆y
 Plot – Pixel (xT , Integer (yT))
= yi + m
 Compute xT = xT + 1
 Compute yi+1 in Real Coordinate space
y T = yT + m
 Truncate to Integer Coordinate space
 End loop

19 20

DDA Example DDA Examlpe


Iteration No X Y |Y |
Draw a Line from P1(2,2) to P2 (12,5) T T

0 2 2 2

Steps 1 3 2.3 2
2 4 2.6 2
• Compute Δx = 10, Δy = 3, m = 0.3
3 5 2.9 2
• m Є (-1,+1), Increment in X direction.
4 6 3.2 3
• X i+1 = x i + 1 5 7 3.5 3
Y i+1 = y i + Δy 6 8 3.8 3
= y i+ m 7 9 4.1 4
8 10 4.4 4
9 11 4.7 4
10 12 5.0 5

21 22

DDA Raster Line DDA Algorithm


Simple to Implement

Limitations

 Floating point Computation

 Speed of algorithm is slow

 Quality of Drawing dependent on slope m

23 24

4
18-08-2024

Bressenham’s Line Drawing Algorithm Bressenham’s Algorithm

 No Floating Point Computation, Truncation

 Evaluates Location of Line between two


Candidate Pixels

 Decides the pixel to be Bright in terms of


midpoint between Pixels
 Above, At, Below
Error e = IM
25

Concept and Steps Bressenham’s Algorithm


 Sign of error e decides if the line intercept is
Above, At, Below M.  Elegant algorithm
 For ∆x =1 say, error e is set at -0.5
 Fast Computation
 Add m to e
 If sign of error e is –ve, choose  No Floating point
yi+1 = yi  Quality (Fidelity) of Line is very Superior
 Else yi+1 = yi +1
 Reset the error e by subtracting 1 from e
 Loop till x ≤ x2
27 28

Comparison of Algorithms

DDA Bressenham

You might also like