Chapter04

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

0 0 3
0 2 1
(0 – 3)
1 2 0
Finite-width line: Counting the number of subpixels whose centers are within the filled rectangle representing the finite width line.
pixel mask pattern
1 0 1 0 1 0 1 0 1 reference position
if (pattern[(y - y0) % ny][(x - x0) % nx] == 1) setPixel (x, y);
(x0, y0): (nx, ny):
Pattern reference position Pattern size
Line Attributes
Line Color
Line Type (Style)
Solid Dashed Dotted Dot-dashed
Solid span
interspan spacing
Implementation of line type
1. Draw solid spans as individual lines 2. Use pixel mask Solid Dashed Dotted Dot-dashed 11111111 11111000 11001100 11110010
yk+0.5
Boundary Line yk y=m(xk-0.5)+b y=m(xk+0.5)+b
yk-0.5 xk-0.5 xk xk+0.5
For m < 1, area of pixel (xk, yk) inside the boundary line y = mx + b is: Ak mxk yk b 0.5
Supersampling of line segments Example: consider each pixel divided into 3 by 3 subpixels.
Zero-width line: Counting the number of subpixels within each pixel.
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
All the implementation methods for line type and line width can be adapted for curves.
r+w/2
r-w/2 r
Area-Fill Attributes
x0 1 2
Area of overlap
x0 1 2
dx
y0 1 2
y0 1 2
dy f ( x, y)rect( x x0 , y y0 )
The pixel intensity is set to be proportional to area of overlap.
Area sampling: Set pixel intensity according to the percent of pixel area inside the boundary.
Pitteway–Watkinson method
Calculate percent of pixel area inside the boundary based on Bresenham’s line-drawing algorithm
Problem • Unequal width for lines with different slopes • End points do not look “right”
2. Draw the line as filled rectangle with line caps
butt caps
Fra Baidu bibliotek
round caps
Character Attributes
Typeface (font)
Style
bold, italics, underline, shadow, Embossed
Size
top cap
character body
kern
character height
base bottom
Hf j
character character width spacing kern
Pixel function:
1, ( x, y ) is inside the pixel rect( x x0 , y y0 ) 0, ( x, y ) is outsidethe pixel
Line function:
1, f ( x, y ) 0, ( x, y ) is inside the line rectangle ( x, y ) is outsidethe line rectangle
Filtering techniques in area-sampling
Weightedarea of overlap
Filter function w(x,y) Box filter x y w( x, y ) rect( , ) h1 h2
Cone filter
(r x 2 y 2 )
Character orientation
Up Vector
Text path
V E R T I C A L
HORIZONTAL
Antialiasing
Aliasing: Distortion of information due to low sampling frequency. The terminology “aliasing” comes from digital signal processing and digital image processing Example of aliasing: Stair step (or jagged) appearance of lines on raster display Another example of aliasing
Nyquist sampling frequency: fs = 2fmax Nyquist sampling interval: xs = 1/ fs fmax is the highest frequency in the object to be sampled.
Sampling theorem: To avoid loss of information (aliasing), the sampling frequency must be at least equal to Nyquist frequency. Methods of antialiasing: • Supersampling (postfiltering): Sampling the object at a higher resolution and display the results at a lower resolution. • Area sampling (prefiltering): Set pixel intensity according to its area of overlap with the object. • Pixel phasing: Shift the locations of the pixels.
Boolean operation of fill pattern with background
Pattern and or
Background xor replace
Merging foreground color with background color P = tF + (1 - t)B P: Pixel color F: Foreground color B: Background color t: Transparency factor
Attributes of Output Primitives
• Line attributes: color, type, width • Area-Fill attributes: color, pattern • Character attributes: font, style, width, height, spacing, orientation etc.
Problem of unequal-length dashed for lines with different slopes
1
2
Solution: Adjust pixel counts for solid spans and interspan spacing according to line slope.
x0 1 2
x0 1 2
dx
y0 1 2
y0 1 2
dy f ( x, y)w( x x0 , y y0 )
1 r r0 , r r0 w( x, y ) 0, r r0
Gaussian filter w( x, y) exp( r 2 r02 )
Antialiasing Area Boundaries Supersampling: Divide each pixel into subpixels. Count the number of subpixels inside the boundary.
(x0, y0)
1
1
The pixel is represented by a unit square centered at (x0, y0).
1 1 1, x and y rect( x, y ) 2 2 0, otherwise
Define rect function as
2
1
4
2
2
1
Finite-width line
0 0 6 1 11 13 15 10 0
(0 – 16)
Area sampling of line segments Calculate the area of overlap of each pixel with the rectangle representing the finite-width line. Subpixel counting method in supersampling can be used to estimate the area of overlap.
Line Width
Implementation of line width 1. Horizontal and vertical pixel spans For m < 1, draw vertical span of pixels at each x location; For m > 1, draw horizontal span of pixels at each y location;
Fill Color
Fill Style
Hollow
Solid
Patterned
Textured
Fill Pattern Fill pattern can be implemented with pixel mask Pattern reference position: Starting pixel position of the lower left corner of the pattern.
projecting square caps
Connecting two lines with different slopes
miter join
round join
bevel join
3. Use pen and brush size shape pattern (use pixel mask)
0 1 8
0 6 5
4 7 0
(0 – 9)
Pixel-weighting mask Give each subpixel different weight
1
2
1
2
1
4
2
2
1
Zero-width line
0 0 6
0 4 1
1 3 0
(0 – 8)
1 Pixel-weighting mask
2
1
相关文档
最新文档