Docsity

Scan Conversion Algorithms for Line and Polygon Drawing in Display Systems, Lecture notes of Computer science

Toggle sidebar
bg1
Overview Lecture 2
●Primitives and Attributes
●Why Scan Conversion?
●Algorithms for
–Scan Conversion
–Lines
–Circles
–Ellipses
–Filling
–Polygons
Refresh
Buffer VC
DP
Advantages
Realistic Shading
No Flickering
Disadvantages
Aliasing
Scan Conversion
Raster Scan System
Display
File DP
Advantages
Light Pen Pick
Built-in Lines
Disadvantages
Flickering
No Realistic Shading
Programming more difficult
Random Scan System
•Problem:
–To represent a perfect image as a bitmapped image.
•We want:
–Fast algorithms.
–Incremental algorithms.
–Avoid floating point.
Scan Conversion Line Drawing Algorithms
●Lines are used a lot - want to get them right.
●Lines should appear straight, not jagged.
–Horiz., vert. and diagonal easy, others difficult
●Lines should terminate accurately.
●Lines should have constant density.
●Line density should be independent of line
length or angle.
●Lines should be drawn rapidly.
–Efficient algorithms.
pf3
pf4
pf5

Partial preview of the text

Download Scan Conversion Algorithms for Line and Polygon Drawing in Display Systems and more Lecture notes Computer science in PDF only on Docsity!

Overview Lecture 2

● Primitives and Attributes

● Why Scan Conversion?

● Algorithms for

– Scan Conversion

– Lines

– Circles

– Ellipses

– Filling

– Polygons

Refresh Buffer

DP VC

Advantages Realistic Shading No Flickering

Disadvantages Aliasing Scan Conversion

Raster Scan System

Display File DP

Advantages Light Pen Pick Built-in Lines

Disadvantages Flickering No Realistic Shading Programming more difficult

Random Scan System

• Problem:

  • To represent a perfect image as a bitmapped image.

• We want:

  • Fast algorithms.
  • Incremental algorithms.
  • Avoid floating point.

Scan Conversion Line Drawing Algorithms

● Lines are used a lot - want to get them right.

● Lines should appear straight, not jagged.

  • Horiz., vert. and diagonal easy, others difficult

● Lines should terminate accurately.

● Lines should have constant density.

● Line density should be independent of line

length or angle.

● Lines should be drawn rapidly.

  • (^) Efficient algorithms.

DDA (Digital Differential

Analyzer) Algorithm

● Faster than brute force.

● Based on Calculating

either ∆x or ∆y.

● Mathematically well

defined.

● Floating point.

● Round off error.

● Time consuming

arithmetic.

DDA Line Drawing Algorithm

LineDDA(int x0, int y0, int xl, int yl) { int dx,dy,steps,k; float xinc,yinc,x,y; dx = x1-x0; dy = y1-y0; if (as(dx) > abs(dy)) steps = abs(dx); else steps = abs(dy);

xinc = dx/steps;

yinc = dy/steps; x = x0; y = y0; DrawPixel(round(x, round(y)); for (k = 1; k <= steps; k++) { x = x + xinc; y = y + yinx; DrawPixel(round(x), round(y)); } }

Bresenhams Line Algorithm

● Accurate

● Efficient

● Integer Calculations

● Uses Symmetry

● Adapted to display

circles, ellipses and

curves.

● Cannot generalize to

arbitrary conics. Thus,

use Midpoint Line

Algorithm.

● It has been proven that

the algorithm gives an

optimal fit for lines.

Midpoint Line Algorithm

● Midpoint: Looks at which side of the line the

midpoint falls on.

● Bresenham: Looks at sign of scaled difference

in errors.

● It has been proven that Midpoint is equivalent

to Bresenhams for lines.

Bresenhams Line

Drawing Algorithm

  1. Input the two line endpoints. Store the left endpoint (x 0 ,y 0 ).
  2. Plot the first point (x 0 ,y 0 ).
  3. Calculate constants ∆x, ∆y, and 2 ∆y - 2∆x and 2 ∆y Get starting values for decision parameter pk. P 0 = 2∆y - ∆x 4. At each xk along the line, starting at k = 0, do the following test: if pk < 0, the next point to plot is (xk + 1, y (^) k ) and pk +1 = p (^) k + 2∆y else, the next point to plot is (xk + 1, y (^) k + 1) and pk +1 = p (^) k + 2∆y - 2∆x 5. Repeat step 4 ∆x times.

Bresenhams Line

Drawing Algorithm

yk+

yk+

yk+

yk

xk xk+1 xk+2 xk+

y = mx + b

xk +

yk + y

yk

d 2

d 1

• Two line segments that share the same pixel.

• Determine which pixels

on each scan line are

within the polygon.

Problem:

Scan Conversion of Polygons

• Find all the polygon edges the scan line

intersects.

• Sort the intersections by increasing x

coordinate.

• Fill all pixels between inter-sections that

are interior to the polygon by using the odd-

parity-rule.

Incremental polygon fill for each scan line:

Scan Conversion of Polygons

Odd-parity-rule:

• Start with even parity and toggle upon

encountering each edge.

• Draw when parity is odd.

Remember:

• y min counts, but y max does not.

• Horizontal lines do not count.

Scan Conversion of Polygons Overview

● Display Technology

  • (^) CRT
  • (^) LCD

● Input Devices

● Output Devices

● Raster Scan Display System

Overview - CRT Display

Technology

● CRT (Cathode-Ray Tube)

● Difficulties with the CRT

● Refresh Rate

● Persistence

● Critical Fusion Frequency

(CFF)

  • Color CRT - Raster Scan
    • (^) Shadow Mask ● (^) Delta-Delta CRT ● (^) Precision In-Line CRT

Cathode Ray Tube (CRT)

● Most common design in display devices

● The main components are:

  • Electron gun
  • (^) Focusing system
  • Deflection coils
  • (^) Phosphor coated screen

Cathode Ray Tube (CRT) Difficulties with the CRT

● Sometimes the convergence point is behind the

screen.

  • (^) The picture appears to be blurred.

● The beam is in focus at the center of the screen.

  • (^) Dynamic focusing.

Display Technology

● Refresh rate:

  • The screen must be updated about 50-60 times per second for raster display.
  • Not dependent on the complexity of the picture.

● Persistence:

  • (^) The time it takes the emitted light from the screen to decay 10% of its original intensity.

● Critical fusion frequency (CFF):

  • (^) The frequency rate when flickering stops and the image become steady.
  • (^) The relation ship between CFF and persistence is non-linear.

Color CRT - Raster Scan

● Shadow Masks - a thin metal plate with small holes

mounted close to the viewing surface

● Delta-Delta CRT

  • (^) Electron guns and phosphor dots are arranged in a triangular triad pattern.

● Precision in-line CRT

  • (^) Electron guns and phosphor dots are in a line.

Color CRT - Raster Scan

• Resolution is limited to the hole size of the

shadow-mask.

  • Smaller holes - better resolution.

• The inside surface of the screen is covered with

red, green and blue phosphor dots.

Liquid Crystal Display (LCD)

● Made up of six layers:

  • (^) Two polarizers (vertical and horizontal)
  • (^) Two thin grid wires (horizontal and vertical)
  • (^) One layer of liquid crystal
  • One reflective layer

Video Controller -

Raster Display

● Constantly refreshing the display.

● Often includes a look-up table.

● Interlaced or non-interlaced.