Computer Graphics
Si Lu
Fall 2017
http://www.cs.pdx.edu/~lusi/CS447/CS447_547_Comput er_Graphics.htm 10/04/2016
1
Computer Graphics Si Lu Fall 2017 - - PowerPoint PPT Presentation
Computer Graphics Si Lu Fall 2017 http://www.cs.pdx.edu/~lusi/CS447/CS447_547_Comput er_Graphics.htm 10/04/2016 1 Last Time Image file formats Color quantization 2 Today Dithering Signal Processing Homework 1 due today
http://www.cs.pdx.edu/~lusi/CS447/CS447_547_Comput er_Graphics.htm 10/04/2016
1
2
3
Black ink is cheaper than color Printing with black ink is simpler and hence cheaper Paper for black inks is not special
4
This formula reflects the fact that green is more representative
NOTE that it is not not the equation implied by the RGB->XYZ color space conversion matrix
Define new array of floating point numbers new_image[i] = old_image[i] / (float)256; To get back:
5
6
0.5 is the threshold This is the naïve version of the algorithm
7
8
0.5 is the threshold This is the naïve version of the algorithm
Compute the average intensity over the image Use a threshold that gives that average For example, if the average intensity is 0.6, use a threshold that is higher than 40% of the pixels, and lower than the remaining 60%
9
10
Typically add uniformly random amount from [-a,a]
For better results, add better quality noise For instance, use Gaussian noise (random values sampled from a normal distribution)
Add a small random color to each pixel before finding the closest color in the table
11
12
13
Break the image into small blocks Define a threshold matrix
Use a different threshold for each pixel of the block Compare each pixel to its
The thresholds can be clustered, which looks like newsprint The thresholds can be “random” which looks better
Threshold matrix
5 9 8 12 15 1 14 4 7 11 6 10 13 3 16 2 16 1
25 . 25 . 25 . 25 . 25 . 5 . 5 . 5 . 25 . 5 . 75 . 75 . 25 . 5 . 75 . 1
1 1 1 1 1
Result
6875 . 3125 . 5625 . 1875 . 125 . 9375 . 8125 . 5 . 4375 . 875 . 1 0625 . 25 . 625 . 375 . 75 .
3125 . 5625 . 5 . 75 . 9375 . 0625 . 875 . 25 . 4375 . 6875 . 375 . 625 . 8125 . 1875 . 1 125 .
Clustered Dot Dispersion
Compute the intensity of each sub-block and index a pattern NOT the same as before
Here, each sub-block has one of a fixed number of patterns – pixel is determined only by average intensity of sub-block In ordered dithering, each pixel is checked against the dithering matrix before being turned on
Used when display resolution is higher than image resolution – not uncommon with printers
Use 3x3 output for each input pixel
17
18
19
Start at one corner and work through image pixel by pixel Usually scan top to bottom in a zig-zag Threshold each pixel Compute the error at that pixel: The difference between what should be there and what you did put there If you made the pixel 0, e = original; if you made it 1, e =
Propagate error to neighbors by adding some proportion of the error to each unprocessed neighbor A mask tells you how to distribute the error Easiest to work with floating point image Convert all pixels to 0-1 floating point More detail in class reading materials
e 3/16 5/16 1/16 7/16
21
Each color channel treated independently
22
23
24
Same color table!
25
Scaling, rotating, morphing, …
Also important for anti-aliasing, later in class
26
27
Pixels in the new image come from their rotated positions in the
These rotated locations might not be in “nice” places
28
New image The positions of the new pixels in the original image
We can view an image as a set of samples from an ideal function If we knew what the function was, we could enlarge the image by resampling the function Failing that, we can reconstruct the function and then resample it
29
reconstruct resample
30
The spectrum is how much of each frequency is present in the function We’re talking about functions, not colors, but the idea is the same
31
d
x i
x i
32
x i
33
34
Two different representations of the same function
f(x) spatial domain F() frequency domain
0.1 0.3 0.5 0.7 0.9 1.1 1.3 1.5
35
1
0.5 1 1.5
36
1
37
The constant function only contains the 0th frequency – it has no wiggles
38
39
2
2
x
They are the same
0.03 0.08 0.13 0.18
0.03 0.08 0.13 0.18
Shar arp p edge ges s giv ive e hig igh h frequ quencies encies Smoot
h var ariat iations ions giv ive lo low frequ quencies encies
sin, cos are band limited Box, Gaussian, etc are not
40
In particular, we can store the Fourier transform of a discrete image in the same amount of space as we can store the image
41
42