Beruflich Dokumente
Kultur Dokumente
1st color
missing colors are simulated by mixing existing colors
2nd color
missing color
2 /54
threshold dithering x ordered dither x stochastic dither x dot diffusion x .... s error diffusion dithering (Floyd-Steinberg)
3 /54
4 /54
Threshold Dithering
every pixel is compared to a threshold t:
t can be: q equal everywhere (e.g. (ba)/2, arbitrary value, mean value, median, ...) q location dependent (defined locally or globally)
Eduard Grller, Thomas Theul 5 /54
p<t p>t
a b
1 1 1 1
7 6 5 4
6 5 4 2
5 4 3 1
4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5
0 0 0 0
9 9 9 0
9 9 0 0
9 0 0 0
Principle of Dithering
available values a, b missing value x between a and b shall be simulated by mixing a-pixels and b-pixels
1/8
5/8 3/8
1/8 7/8
5/8 ...
1
7/8
interval borders
1/8
3/8
5/8
7/8
1/8
= "Threshold Matrix"
10 /54
Threshold Matrix
distances between interval borders are equal, therefore it suffices to define the sequence of the pixel values in the matrix:
7 0 5
2 4 6
3 8 1
1/8
5/8
2 1
instead of
7/8 3/8
only
3
15 18 1 18 11 18
5 7 18 18 9 17 18 18 13 3 18 18
2k+1 2n2
12 /54
2k+1 2n2
11 /54
1 1 1 1
7 6 5 4
6 5 4 2
5 4 3 1
1.1 5.6 1.1 5.6 7.9 3.4 7.9 3.4 1.1 5.6 1.1 5.6 7.9 3.4 7.9 3.4
0 0 0 0
9 9
0
9
0
9
0 0
0 2 3 1
...
k= 0(1)n2-1
4k+0
4k+2
9
0
example: 0 12 3 15
Eduard Grller, Thomas Theul
8 4 11 7
2 14 1 13
10 6 9 5
4k+3
4k+1
14 /54
example
calculation is done separately for every pixel (not once for a dithering matrix)
Eduard Grller, Thomas Theul 16 /54
result
1 1 1 1
7 6 5 4
6 5 4 2
5 4 3 1
0.4 7.9 3.4 4.9 2.6 3.4 5.6 4.1 0.4 4.9 3.4 1.9 2.6 4.1 2.6 1.1
6 6 6 3
6 3 6
6 3 3
0
3
11 16 12 8 4 5 15 17 13 3 0 1 10 14 9 7 2 6
simulates traditional printing techniques for high resolution devices
Eduard Grller, Thomas Theul 18 /54
0
17 /54
0 11 12 7
14 3 5 8 2 15 9 4
13 6 1 10
Stochastic Dithering?
use of random numbers as threshold values
s expectation s no
19 /54
r1 := round (k1) error1 := r1 k1 r2 := round (k2 error1) error2 := r2 (k2 error1) ... ri := round (ki errori1) errori := ri (ki errori1)
21 /54 Eduard Grller, Thomas Theul 22 /54
5 3 1 4 2 1
23 /54
24 /54
Serpentine Method
artificial stripes can be reduced drastically by processing the scanlines in serpentine order instead of "normal" now in "serpentines"
x 1 1
result
1 1 1 1
7 6 5 4
6 5 4 2
5 4 3 1
0
3
9 6 3 6
6 3 6
6 3 3 3
25 /54
1.5 1.5 -.87 -.75 -.25 -1.37 .87 .06 -1.12 .75 -1.12 1.47
0 0
...
no additional memory necessary
Eduard Grller, Thomas Theul
...
26 /54
Raster Conversion
converting primitives (lines etc.) into pixels very frequent operations, therefore necessary: s efficiency s possibility to implement in hardware
27 /54
28 /54
Simple DDA
symmetric DDA produces lines of variable breadth, but if x and y are chosen such that max(|x|, |y|) = 1 only 1 pixel per unit in the longer direction
problem: requires a real division solution: Bresenham Algorithm image equal to simple DDA, but no division
NO
STOP
29 /54 Eduard Grller, Thomas Theul 30 /54
S T
symmetric DDA
Eduard Grller, Thomas Theul
simple DDA
31 /54
only for lines with angle 45 other lines by mirroring/rotating with 90/180...
Eduard Grller, Thomas Theul 32 /54
if yD yH < 0 if yD yH > 0
decision variable
33 /54 Eduard Grller, Thomas Theul 34 /54
36 /54
and
y=r
T S
d = "decision variable" i.e. dold = d = f(xp+1, yp1/2) , then dnew can be calculated as follows:
Eduard Grller, Thomas Theul 38 /54
41 /54
criterion:
T S
40 /54
42 /54
Raster Transformations
how to apply geometrical transformations to raster images? translation: trivial scaling: resampling necessary s shearing: by line conversion s rotation: partition in three shearings
s s
Shearing
x-shearing
(x y) 1 0 = (x+y y) 1
y-shearing
(x y) 1 = (x y+x) 0 1
46 /54
Raster Shearing
Raster Rotation
90-rotation, 180-rotation, etc. trivial
principle of other rotations: subdivide rotation in a series of three shears
can be seen as the multiple application of a line raster conversion algorithm (e.g. Bresenham) no information lost
1 0 . 1 . 1 0 1 0 1 1
47 /54
Rotation = 3 Shears
tan (/2) = (1- cos ) / sin 1 cos 1 sin 0. 1 1 sin 0 1 . 1 0 cos 1 1 = sin
Example: 45 Rotation
1 cos 1 sin
sin 1+ cos 1 cos sin cos 1+ cos2 cos cos = -sin cos sin
Eduard Grller, Thomas Theul 49 /54 Eduard Grller, Thomas Theul 50 /54
Example: 45 Rotation
Example: 45 Rotation
tan (/2) = 0.4142 sin = 0.7071
51 /54
52 /54
(u,v) are calculated from (x,y) by interpolation from the corner coordinates
Eduard Grller, Thomas Theul 54 /54