cst 494/598 computer graphics anshuman razdan [email protected] i3dea.asu.edu/razdan
Post on 20-Dec-2015
224 views
TRANSCRIPT
A Razdan and Peter Wonka 2
Disclaimer
These slides can only be used as study material for the class 470 at ASUThe slides cannot be distributed or used for another purposeThe slides may contain errorsThe slides do not contain all the information necessary to succeed in class; additional material from the book must to be studiedThe slides are based on a lecture from Prof. Purgathofer from the Vienna University of Technology
A Razdan and Peter Wonka 4
Color and Gray Scale
color information: RGBcolor codes directly in frame buffer
1024 x 1024 x 24 bit/color 3 Mbyte storage
color (lookup) tables
less storage
easy change of color table(e.g., for color coding)
gray scalecalculated from RGB
e.g. intensity = 0.5 [min(r,g,b) + max(r,g,b)]
red green blue Farbe 0 0 0 black 0 0 1 blue 0 1 0 green 0 1 1 cyan 1 0 0 red 1 0 1 magenta 1 1 0 yellowyellow 1 1 1 white
A Razdan and Peter Wonka 5
Color Lookup Table
i
j
r i
j
g i
j
b
i
j
xxxx r g b
instead of:
now: selected colors addressed by table index
A Razdan and Peter Wonka 6
Line Attributes (1)
type solid, dashed, dotted,…
pixel mask (raster line algorithms)
width Bresenham + additional vertical (horizontal) spans
width dependent on line slope
line caps
A Razdan and Peter Wonka 7
Line Attributes (2)width
thick lines as filled rectangles joining two segments: miter round bevel
pen and brush options shape, size, pattern pixel mask simulation of brush strokes
color
A Razdan and Peter Wonka 8
Area-Fill Attributes (1)
fill styleshollow with color border
filled with solid color
filled with specific pattern or design (e.g., hatch,…)
A Razdan and Peter Wonka 9
Area-Fill Attributes (2)
fill optionsedge type, width, color
pattern specificationthrough pattern tables
tiling (pattern reference point)
4 00 4
startposition
pixel startposition
4 00 4
4 00 4
4 00 4
4 00 4
4 00 4
4 00 4
4 00 4
4 00 4
4 00 4
4 00 4
4 00 4
4 00 4
A Razdan and Peter Wonka 10
Area-Fill Attributes (3)
combination of fill pattern with background colors
soft fillcombination of colors
antialiasing at object borders
simulation of semitransparent brushes
example: linear soft-fill
pattern back- ground
and
or
xor
replace
F...foreground colorB...background color
BttFP )1(
A Razdan and Peter Wonka 11
Scan-Line Polygon-Fill Algorithm
interior pixels along a scan line passing through a polygon area
A Razdan and Peter Wonka 12
Scan-L. Fill: Intersecting Vertices
intersection points along scan lines that intersect poly-gon vertices. y: odd number of intersectionsy’: even number of intersections (bad) can be paired for correct interior pixel spans
A Razdan and Peter Wonka 13
Scan-L. Fill: Incremental Update
incremental update of intersection point
kk
kk
xxyy
m
1
1
11 kk yy
mxx kk
11
yx
xx kk 1
slope of polygon boundary line: m
(for 2 successive scanlines)
A Razdan and Peter Wonka 14
Scan-L. Fill: Sorted Edge Table
sort all edges on smallest y-valueedge entry: [max y-value, x-intercept, inverse slope]
active-edge list for each scan linecontains all edges crossed by that scan lineincremental update
consecutive intersection pairs (spans) filled
A Razdan and Peter Wonka 15
Sorted Edge Table: Example
a polygon and its sorted edge table, with edge DC shortened by 1 unit
A Razdan and Peter Wonka 16
Scan-Line Fill: Active-Edge List
active-edge list for -DC’ - DE - AE - AB
A Razdan and Peter Wonka 18
Flood-Fill Algorithm
pixel filling of areaareas with no single color boundary
start from interior point
“flood” internal region
4-connected, 8-connected areas
reduce stack size by eliminating several recursive calls
A Razdan and Peter Wonka 19
Flood-Fill: Definition of Boundary
area must be distinguishable from boundaries
example: area definedwithin multiple colorboundaries
A Razdan and Peter Wonka 20
Flood-Fill: Connectedness
Definition: 4-connected means, that a connection is only valid in these 4 directions
Definition: 8-connected means, that a connection is only valid in these 8 directions
A Razdan and Peter Wonka 21
Example for 4- and 8-connected
a 4-connected area an 8-connected areaa 4-connected area has an 8-connected border
an 8-connected area has a 4-connected border
A Razdan and Peter Wonka 24
Span Flood-Fill Algorithm
floodFill4 produces too high stacks (recursion!)
solution: incremental horizontal fill (left to right)
recursive vertical fill (first up then down)
A Razdan and Peter Wonka 30
Span Flood-Fill Example
12 13 14 s4
4 5 6 7 8 9 10 11
s3 1 2 3 s2
s1
16 17 1815
A Razdan and Peter Wonka 31
Span Flood-Fill Example
15 16 17 18
12 13 14 19
4 5 6 7 8 9 10 11
s3 1 2 3 s2
s1
A Razdan and Peter Wonka 32
Span Flood-Fill Example
12 13 14
s4 4 5 6 7 8 9 10 11
20 21 22 1 2 3 s2
s3 s1
15 16 17 18
19
A Razdan and Peter Wonka 33
Span Flood-Fill Example
12 13 14
23 4 5 6 7 8 9 10 11
20 21 22 1 2 3 s2
s3 s1
15 16 17 18
19
A Razdan and Peter Wonka 34
Span Flood-Fill Example
12 13 14
23 4 5 6 7 8 9 10 11
20 21 22 1 2 3 s2
24 25 s1
s3
15 16 17 18
19
A Razdan and Peter Wonka 35
Span Flood-Fill Example
12 13 14
23 4 5 6 7 8 9 10 11
20 21 22 1 2 3 s2
24 25 s1=s5
26 27 28 29 30
s4 s3
15 16 17 18
19
A Razdan and Peter Wonka 36
Span Flood-Fill Example
12 13 14
23 4 5 6 7 8 9 10 11
20 21 22 1 2 3 s2
24 25 31 32 33
26 27 28 29 30
s4 s3
15 16 17 18
19
A Razdan and Peter Wonka 37
Span Flood-Fill Example
12 13 14
23 4 5 6 7 8 9 10 11
20 21 22 1 2 3 s2
24 25 31 32 33
26 27 28 29 30
34 35 s3
15 16 17 18
19
A Razdan and Peter Wonka 38
Span Flood-Fill Example
12 13 14
23 4 5 6 7 8 9 10 11
20 21 22 1 2 3 s2
24 25 31 32 33
26 27 28 29 30
34 35 36 37
15 16 17 18
19
A Razdan and Peter Wonka 39
Span Flood-Fill Example
12 13 14
23 4 5 6 7 8 9 10 11
20 21 22 1 2 3 38
24 25 31 32 33
26 27 28 29 30
34 35 36 37
15 16 17 18
19
A Razdan and Peter Wonka 40
text attributesfont (e.g. Courier, Arial, Times, Roman, …)
styles (regular, bold, italic, underline,…)
size (32 point, 1 point = 1/72 inch)
proportionally sized vs. fixed space fonts
string attributesorientation
alignment (left, center, right, justify)
Character Attributes
vertical
horizontal
slanted
Displayed primitives generated by the raster algorithms discussed in Chapter 3 have a jagged, or stairstep, appearance.
Displayed primitives generated by the raster algorithms
discussed in Chapter 3 have a jagged, or
stairstep, appearance.
Displayed primitives generated by the raster algorithms
discussed in Chapter 3 have a jagged, or
stairstep, appearance.
Displayed primitives generated by the raster algorithms discussed in Chapter 3 have a jagged, or stairstep, appearance.
A Razdan and Peter Wonka 41
Antialiasing
what is aliasing?
what is the reason for aliasing?
what can we do against it?
A Razdan and Peter Wonka 42
What is Aliasing?
not enough resolution
not enough colors
not enough images / sec
geometric errors
numeric errors
errors that are caused by the discretization of analog data to digital data
A Razdan and Peter Wonka 46
Aliasing in Animations
jumping images"worming“
backwards rotating wheels
t
A Razdan and Peter Wonka 48
Solutions against Aliasing?
1. improve the deviceshigher resolution
more color levels
faster image sequence
2. improve the imagespostprocessing
antialiasing !
expensiveor
incompatible
software
A Razdan and Peter Wonka 49
Shannon Sampling Theorem
a signal can only be reconstructed without information loss if the sampling frequency is at least twice the highest frequency of the signal
this border frequency is called "Nyquist Limit"
A Razdan and Peter Wonka 50
Shannon Sampling Theorem
Nyquistsamplinginterval
sampling rate
original signal
reconstructed signal
A Razdan and Peter Wonka 51
Antialiasing: Nyquist Sampling Frequency
a signal can only be reconstructed without information loss if the sampling frequency is at least twice the highest frequency of the signal
maxcycle /1x with2
fx
x cycles
i.e. sampling interval one-half cycle interval
max2 ff s Nyquist sampling frequency:
A Razdan and Peter Wonka 52
supersampling straight-line segments
subpixel weighting masks
area sampling straight-line segments
filtering techniques
compensating for line-intensity differences
antialiasing area boundaries(adjusting boundary pixel positions)
adjusting boundary pixel intensity
Antialiasing Strategies
A Razdan and Peter Wonka 53
Antialiasing: Supersampling Lines
00 00 1100 22 2233 11 00
00 00 4411 66 8888 55 00
3 = max. intensity...0 = min. intensity
9 = max. intensity...0 = min. intensity
thin line line of finite width
A Razdan and Peter Wonka 55
Antialiasing: Area Sampling Lines
calculate the pixel coverage exactly
can be done with incremental schemes
00%% 00%% 4343
1515 7171 8484
9090 5252 33%%
A Razdan and Peter Wonka 56
Antialiasing: Pixel Weighting Masks
relative weights for a grid of 3x3 subpixels
more weight for center subpixels
must be divided by sum of weights
subpixel grids can also include some neighboring pixels
A Razdan and Peter Wonka 57
Antialiasing: Filtering Techniques
box filter cone filter Gaussian filter
continuous overlapping weighting functions to calculate the antialiased values with integrals
A Razdan and Peter Wonka 58
Antialiasing: Compensating for Intensity Differences
unequal line lengths displayed with the same number of pixels in each line/row have different intensities
proper antialiasing compensates for that!
A Razdan and Peter Wonka 60
Antialiasing Area Boundaries (1)
adjusting pixel intensities along an area boundary
alternative 1:supersampling
A Razdan and Peter Wonka 61
Antialiasing Area Boundaries (2)
alternative 2: like midpoint line algorithm
p´ = y ymid = [m(xk + 1) + b] (yk + 0.5)
p´<0 y closer to yk
p´>0 y closer to yk+1
p = p´+ (1m) :p<1m closer to yk
p>1m closer to yk+1
( and p [0,1] )
yymid
Note: We add (1-m) so that the decision parameter p = area covered by polygon!
A Razdan and Peter Wonka 62
Antialiasing Area Boundaries (3)
p = p´+(1-m) = [m(xk + 1) + b] (yk + 0.5) + (1 m)= mxk + b yk + 0.5
=
xk xk+1
yk
yk+ 0.5p for next pixel= overlap areafor current pixel
p´
p = p´-m+1 = p´+(1-m)
mp´-m