Presentation is loading. Please wait.

Presentation is loading. Please wait.

Primitive Drawing Algorithm

Similar presentations


Presentation on theme: "Primitive Drawing Algorithm"— Presentation transcript:

1 Primitive Drawing Algorithm
Graphics Laboratory Korea University

2 Contents Output Primitives Color Models
How can we describe shapes with primitives? Color Models How can we describe and represent colors?

3 Output Primitives Points Lines Polygons DDA algorithm
Bresenham’s algorithm Polygons Scan-line polygon fill Inside-outside tests Boundary-fill algorithm Anti-aliasing

4 Points Single coordinate position
Set the color of the specified screen position Within the frame buffer x y

5 Lines Intermediate positions between two endpoints
DDA, Bresenham’s line algorithms Jaggies / Aliasing

6 DDA Algorithm Digital differential analyzer (DDA) Algorithm overview
Scan-conversion line algorithm for Based on calculating either y or x Algorithm overview Sample the line at unit intervals in one coordinate If |m| is below 1, sample in x coordinate Else, sample in y coordinate Determine corresponding integer values in other coordinate Until the final endpoint is reached

7 In the Case of |m| < 1 y y x x : Lost Pixel <When we sample
in x coordinate> <When we sample in y coordinate>

8 Bresenham’s Line Algorithm (1 / 3)
Accurate and efficient Use only incremental integer calculations Can be adapted to circles and other curves Specified Line Path 12 11 A 10 B 10 11 12 Which pixel is appropriate, A or B?

9 Bresenham’s Line Algorithm (2 / 3)
Vertical pixel separation as d1, d2 From the mathematical line path If d1-d2 < 0, yk is selected Else, yk+1 is selected xk+1 yk yk+1 y d2 d1 |m| < 1

10 Bresenham’s Line Algorithm (3 / 3)
Decision parameter pk The sign of pk is same as the sign of d1-d2 Due to x > 0 Parameter c is constant Independent of pixel position Incremental representation

11 Polygons Filling polygons Scan-line fill algorithm
Inside-outside test Boundary fill algorithm 11 1 2 3 4 5 6 7 8 9 10 5 6 7 8 9 4 3 1 2

12 Scan-Line Polygon Fill
Topological difference between 2 scan lines y: intersection edges are opposite sides y’: intersection edges are same side y 1 2 2 y’ 1 1

13 Scan-Line Polygon Fill (cont.)
Edge Sorted Table B yC yB xC 1/mCB C C’ E yD yC’ xD 1/mDC yE xD 1/mDE D yA yE xA 1/mAE yB xA 1/mAB A 1 Scan-Line Number

14 Inside-Outside Tests Self-Intersections Odd-Even rule
Nonzero winding number rule exterior interior

15 Boundary-Fill Algorithm
Proceed to Neighboring Pixels 4-Connected 8-Connected

16 Antialiasing Supersampling (postfiltering)
Pixel-weighting masks Area Sampling (prefiltering) Pixel phasing Shift the display location of pixel areas Micropositioning the electron beam in relation to object geometry

17 Supersampling Subpixels increase resolution Maximum intensity level: 9
22 (10, 20): Level 3 Intensity (11, 20): Level 1 Intensity (11, 21): Level 2 Intensity (12, 20): Level 3 Intensity 21 20 10 11 12

18 Weighted Supersampling
Pixel-weighting masks More weights to subpixels near the center Maximum intensity level: 16 More variations in pixel intensity 1 2 4

19 Weighted Supersampling
22 (10, 20): Level 7 Intensity (11, 20): Level 1 Intensity (11, 21): Level 3 Intensity (12, 20): Level 5 Intensity 21 20 10 11 12

20 Area Sampling Intensity is proportional to overlapped area of each pixel 2 adjacent vertical (or horizontal) screen grid lines  trapezoid 22 (10, 20): 90% (10, 21): 10% 21 20 10 11 12

21 Filtering Techniques Filter Functions (Weighting Surface) Box Filter
Cone Filter Gaussian Filter

22 Contents Output Primitives Color Models
How can we describe shapes with primitives? Color Models How can we describe and represent colors?

23 Color Frame Buffer 255 150 75 255 150 75 255 150 75 Blue channel
255 150 75 255 150 75 Blue channel Green channel Red channel

24 Color Models RGB CMY HSV

25 RGB Color Model R G B Color Colors are additive 0.0 0.0 0.0 Black 1.0
Red 0.0 1.0 0.0 Green 0.0 0.0 1.0 Blue 1.0 1.0 0.0 Yellow 1.0 0.0 1.0 Magenta 0.0 1.0 1.0 Cyan 1.0 1.0 1.0 White

26 RGB Color Cube

27 CMY Color Model C M Y Color Colors are subtractive 0.0 0.0 0.0 White
1.0 0.0 0.0 Cyan 0.0 1.0 0.0 Magenta 0.0 0.0 1.0 Yellow 1.0 1.0 0.0 Blue 1.0 0.0 1.0 Green 0.0 1.0 1.0 Red 1.0 1.0 1.0 Black

28 CMY Color Cube

29 HSV Color Model Spectral color (Hue) Amount of white (Saturation)
Black (Value) Hue Angle Saturation

30 HSV Color Model H S V Color 1.0 1.0 Red 60 1.0 1.0 Yellow 120 1.0 1.0
1.0 1.0 Red 60 1.0 1.0 Yellow 120 1.0 1.0 Green 180 1.0 1.0 Cyan 240 1.0 1.0 Blue 300 1.0 1.0 Magenta * 0.0 1.0 White * 0.0 0.5 Gray * * 0.0 Black

31 HSV Color Model Cross section of the HSV hexcone


Download ppt "Primitive Drawing Algorithm"

Similar presentations


Ads by Google