0% found this document useful (0 votes)
68 views6 pages

12 RasterConversion PDF

This document discusses algorithms for raster conversion of lines and circles in computer graphics. It covers the Digital Differential Analyzer (DDA) and Bresenham's algorithms for drawing lines, and direct method, polar coordinates, and Bresenham's algorithm for generating circles. It also discusses antialiasing techniques for minimizing distortion when representing smooth graphics on pixelated displays.
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)
68 views6 pages

12 RasterConversion PDF

This document discusses algorithms for raster conversion of lines and circles in computer graphics. It covers the Digital Differential Analyzer (DDA) and Bresenham's algorithms for drawing lines, and direct method, polar coordinates, and Bresenham's algorithm for generating circles. It also discusses antialiasing techniques for minimizing distortion when representing smooth graphics on pixelated displays.
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/ 6

Raster conversion algorithms for line

and circle
Graphics 2
Line drawing algorithms
06-02408
- DDA (Digital Differential Anayzer)
- Bresenham
Level 3
Circle generating algorithms
10 credits in Semester 2 - Direct method
- Bresenham algorithm
Professor Aleš Leonardis

Slides by Professor Ela Claridge

Raster conversion algorithms:


Pixel addressing in raster graphics
requirements

Theoretical length
Pixel
address

y •  visual accuracy
y+1
Pixel
•  spatial accuracy
y+2

y+3
•  speed
x x+1 x+2 x+3 x+4

Actual length

1
Line (segment) drawing algorithms Line – raster representation

symbols & images


descriptions
y = 2x + 5
x0 = 100
y0 = 50
d = 100

thickness = 4

Simple line equation Line gradient (slope)

m = Δy / Δx m =∞
|m| > 1, m > 0
m=1
y = mx + b
m = slope (gradient) |m| < 1, m > 0
b= intercept with y axis b
m=0
m = Δy / Δx

m = -1

2
DDA (digital differential analyzer) DDA ( Digital Differential Analyzer )

|m| < 1, m > 0

DDA ( Digital Differential Analyzer ) DDA ( Digital Differential Analyzer )


|m| > 1, m > 0
|m| > 1, m > 0

3
y = mx + b

Bresenham's line algorithm Bresenham's line algorithm (slope ≤ 1)

y = mx + b •  input line endpoints, (x0,y0) and (xn, yn)


•  calculate Δx = xn - x0 and Δy = yn - y0
•  calculate parameter p1 = 2 Δy - Δx
•  set pixel at position (x0,y0)
•  repeat the following steps until (xn, yn) is reached:
y = m(x+1) + b d2 •  if pi < 0
y d1 •  set the next pixel at position (xi +1, yi )
•  calculate new pi+1 = pi + 2 Δy
x x+1 •  if pi ≥ 0
•  set the next pixel at position (xi +1, yi + 1 )
•  calculate new pi+1 = pi + 2(Δy - Δx)
For derivation see http://www.cs.bham.ac.uk/~exc/Teaching/Graphics/Bresenham_derivation.pdf

Circle generating algorithms Direct circle algorithm

•  Cartesian coordinates
•  Direct
•  Polar coordinate based
•  Circle equation:
•  Bresenham s
( x - x c )2 + ( y - y c )2 = r 2

•  Step along x axis from xc - r to xc + r and


calculate
y = y c ± √ r2 - ( x - x c ) 2

4
Polar coordinates Optimisation and speed-up

•  Polar coordinate equation (parametric, w.r.t. ϕ) •  Symmetry of a (-x,y) (x,y)


circle can be used
x = xc + r cosϕ
y = yc + r sinϕ
•  Calculations of (-y,x) (y,x)
•  step through values of ϕ from 0 to 2π point coordinates
only for a first one- (-y,-x)
eighth of a circle (y,-x)

•  Assumes (xc,yc)= (-x,-y) (x,-y)


(0,0)

While x < y
Bresenham s circle algorithm if pk < 0
pk+1 = pk + 4xk + 6
•  Assumes centre at (0,0) xk+1 = x + 1
yk+1 = yk
Initialisation else
•  Input radius r pk+1 = pk + 4(xk – yk ) + 10
•  Plot a point at x0=0, y0=r xk+1 = xk + 1
•  Set k = 0 yk+1 = yk – 1
•  Calculate the initial value of the decision parameter
plot point at (xk+1 , yk+1)
p0 = 3 - 2r
increment k

5
Antialiasing Next topic

•  The technique of
minimizing the distortion Splines and spline surfaces
artifacts arising due to
representing smooth
and continuous entities
(fonts, lines, curves) on
a discrete (pixelated)
display.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy