Graphics

Raster Graphics

cgvr.korea.ac.kr

Graphics Lab @ Korea University

Contents 

Display Hardware 

How are imaging system organized

Output Primitives 

How are images display?

Raster Graphics Systems 

CGVR

How can we describe shapes with primitives?

Color Models 

How can we describe and represent colors?

Graphics Lab @ Korea University

Bresenham’s Line Algorithm 

Accurate and Efficient  

CGVR

Use only incremental integer calculations Test the sign of an integer parameter

Case) Positive Slope Less Than 1 

After the pixel (xk, yk) is displayed, next which pixel is decided to plot in column xk+1? y +1 k

 (xk+1, yk) or (xk+1, yk+1)

yk xk xk+1 Graphics Lab @ Korea University

Bresenham’s Algorithm(cont.) 

CGVR

Case) Positive Slope Less Than 1 

y at sampling position xk

Difference d1 = y − yk = m( xk + 1) + b − yk yk+1 d 2 = yk + 1 − y = yk + 1 − m( xk + 1) − b y k d1– d2 < 0  (xk+1, yk)

y = m( xk + 1) + b

d1– d2 > 0  (xk+1, yk+1) Decision parameter pk = ∆x( d1 − d 2 )

d2 d1 xk xk+1

= 2∆y ⋅ xk − 2∆x ⋅ yk + 2∆y + ∆x( 2b − 1) = 2∆y ⋅ xk − 2∆x ⋅ yk + c Graphics Lab @ Korea University

Bresenham’s Algorithm(cont.) 

CGVR

Case) Positive Slope Less Than 1 

Decision parameter

pk +1 − pk = ( 2∆y ⋅ xk +1 − 2∆x ⋅ yk +1 + c ) − ( 2∆y ⋅ xk − 2∆x ⋅ yk + c ) = 2∆y ( xk +1 − xk ) − 2∆x( yk +1 − yk )

∴ pk +1 = pk + 2∆y − 2∆x( yk +1 − yk ) 

Decision parameter of a starting pixel (x0, y0) p0 = 2∆y ⋅ x0 − 2∆x ⋅ y0 + 2∆y + ∆x( 2b − 1)

= 2∆y ⋅ x0 − 2∆x ⋅ ( mx0 + b ) + 2∆y + ∆x( 2b − 1) = 2∆y ⋅ x0 − 2∆y ⋅ x0 − 2b∆x + 2∆y + 2b∆x − ∆x

∴ p0 = 2∆y − ∆x Graphics Lab @ Korea University

Bresenham’s Algorithm(cont.) 

CGVR

Algorithm for 0<m<1 

Input the two line endpoints and store the left end point in (x0, y0)

Load (x0, y0) into the frame buffer; that is, plot the first point

Calculate constants Δx, Δy, 2Δy, and 2Δy− 2Δx, and obtain the starting value for the decision parameter as

p0 = 2∆y − ∆x

At each xk along the line, start at k =0, perform the following test: 

If pk < 0, the next point to plot is (xk+1, yk) and

Otherwise, the next point to plot is (xk+1, yk+1) and

pk +1 = pk + 2∆y

pk +1 = pk + 2∆y − 2∆x

Repeat step 4 Δx times Graphics Lab @ Korea University

Polygons 

CGVR

Filling Polygons 

Scan-line fill algorithm 

Boundary fill algorithm

Inside-Outside tests

1 2 3 4

5 6 7 8 9

11 10 5 6 7 8 9

4312

Graphics Lab @ Korea University

Scan-Line Polygon Fill 

CGVR

Topological Difference between 2 Scan lines  

y y’

y : intersection edges are opposite sides y’ : intersection edges are same side

1

2 2 1

1

Graphics Lab @ Korea University

Scan-Line Polygon Fill (cont.) 

CGVR

Edge Sorted Table B

yC

yB xC

1/mCB

yD

yC’ xD

1/mDC

yE xD

1/mDE

yA

yE xA

1/mAE

yB xA

1/mAB

C C’

E D A

1 Scan-Line Number 0 Graphics Lab @ Korea University

Inside-Outside Tests 

CGVR

Self-Intersections 

Odd-Even rule

Nonzero winding number rule

exterior interior

Graphics Lab @ Korea University

Boundary-Fill Algorithm 

CGVR

Proceed to Neighboring Pixels  

4-Connected 8-Connected

Graphics Lab @ Korea University

Antialiasing 

CGVR

Aliasing 

Undersampling: Low-frequency sampling

original

sample

reconstruct

 

Nyquist sampling frequency: f s = 2 f max ∆x Nyquist sampling interval: ∆xs = cycle 2 Graphics Lab @ Korea University

Antialiasing (cont.) 

Supersampling (Postfiltering) 

 

CGVR

Area Sampling (Prefiltering) Pixel Phasing  

Shift the display location of pixel areas Micropositioning the electron beam in relation to object geometry

Graphics Lab @ Korea University

Supersampling 

CGVR

Subpixels 

Increase resolution

22 (10, 20): Maximum Intensity 21

(11, 21): Next Highest Intensity (11, 20): Lowest Intensity

20 10

11

12

Graphics Lab @ Korea University

Supersampling 

CGVR

Subpixels 

Increase resolution

22 (10, 20): Maximum Intensity 21

(11, 21): Next Highest Intensity (11, 20): Lowest Intensity

20 10

11

12

Graphics Lab @ Korea University

CGVR

Give More Weight to Subpixels Near the Center of a Pixel Area

1 2 1

2 4 2

1 2 1

Graphics Lab @ Korea University

Area Sampling 

CGVR

Set Each Pixel Intensity Proportional to the Area of Overlap of Pixel 

2 adjacent vertical (or horizontal) screen grid lines  trapezoid 22 (10, 20): 90%

21

(10, 21): 15%

20 10

11

12 Graphics Lab @ Korea University

Filtering Techniques ď Ž

CGVR

Filter Functions (Weighting Surface)

Box Filter

Cone Filter

Gaussian Filter Graphics Lab @ Korea University

Contents 

Display Hardware 

How are imaging system organized?

Output Primitives 

How are images display?

Raster Graphics Systems 

CGVR

How can we describe shapes with primitives?

Color Models 

How can we describe and represent colors?

Graphics Lab @ Korea University

Electromagnetic Spectrum 

CGVR

Visible Light Frequencies Range between  

Red: 4.3 x 1014 hertz (700nm) Violet: 7.5 x 1014 hertz (400nm)

Graphics Lab @ Korea University

Visible Light 

CGVR

The Color of Light is Characterized by   

Hue: dominant frequency (highest peak) Saturation: excitation purity (ratio of highest to rest) Brightness: luminance (area under curve)

White Light

Orange Light Graphics Lab @ Korea University

Color Perception 

CGVR

Tristimulus Theory of Color 

Spectral-response functions of each of the three types of cones on the human retina

Graphics Lab @ Korea University

Color Models     

CGVR

RGB XYZ CMY HSV Others

Graphics Lab @ Korea University

RGB Color Model ď Ž

CGVR

R

G

B

0.0 1.0 0.0 0.0 1.0

0.0 0.0 1.0 0.0 1.0

0.0 Black 0.0 Red 0.0 Green 1.0 Blue 0.0 Yellow

1.0 0.0 0.0 1.0 1.0 1.0

Color

1.0 Magenta 1.0 Cyan 1.0 White Graphics Lab @ Korea University

RGB Color Cube

CGVR

Graphics Lab @ Korea University

RGB Spectral Colors ď Ž

CGVR

Amounts of RGB Primaries Needed to Display Spectral Colors

Graphics Lab @ Korea University

XYZ Color Model (CIE) ď Ž

CGVR

Amounts of CIE Primaries Needed to Display Spectral Colors

Graphics Lab @ Korea University

CIE Chromaticity Diagram ď Ž

CGVR

Normalized Amounts of X and Y for Colors in Visible Spectrum

(white)

Graphics Lab @ Korea University

CIE Chromaticity Diagram

Define Color Gamuts

Represent Complementary Color

CGVR

Determine Dominant Wavelength and Purity

Graphics Lab @ Korea University

RGB Color Gamut ď Ž

CGVR

Color Gamut for a Typical RGB Computer Monitor

(green)

(red)

(blue)

Graphics Lab @ Korea University

CMY Color Model ď Ž

Colors are Subtractive

CGVR

C

M

Y

0.0 1.0 0.0 0.0 1.0

0.0 0.0 1.0 0.0 1.0

0.0 White 0.0 Cyan 0.0 Magenta 1.0 Yellow 0.0 Blue

1.0 0.0 0.0 1.0 1.0 1.0

Color

1.0 Green 1.0 Red 1.0 Black Graphics Lab @ Korea University

CMY Color Cube

CGVR

Graphics Lab @ Korea University

HSV Color Model ď Ž

CGVR

Select a Spectral Color (Hue) and the Amount of White (Saturation) and Black (Value)

Graphics Lab @ Korea University

HSV Color Model

CGVR

H

S

0 60 120 180 240 300 * * *

1.0 1.0 1.0 1.0 1.0 1.0 0.0 0.0 *

V

Color

1.0 Red 1.0 Yellow 1.0 Green 1.0 Cyan 1.0 Blue 1.0 Magenta 1.0 White 0.5 Gray 0.0 Black Graphics Lab @ Korea University

HSV Color Model ď Ž

CGVR

Cross Section of the HSV Hexcone

Graphics Lab @ Korea University

03raster_1

Raster Graphics cgvr.korea.ac.kr Graphics Lab @ Korea University  Color Models  Output Primitives  How are imaging system organized ...