02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding...
-
Upload
coral-chase -
Category
Documents
-
view
214 -
download
0
Transcript of 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding...
![Page 1: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/1.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Last Time
• Color Quantization
• Mach Banding– Humans exaggerate sharp boundaries, but not fuzzy ones
![Page 2: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/2.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Today
• Homework 1 is due– Box up front
• Dithering (Digital Halftoning)
![Page 3: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/3.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Dithering (Digital Halftoning)
• Mach bands can be removed by adding noise along the boundary lines
• General perceptive principle: replaced structured errors with noisy ones and people complain less
• Old industry dating to the late 1800’s– (Can’t say since the turn of the century!)
– Methods for producing grayscale images in newspapers and books
![Page 4: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/4.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Dithering to Black-and-White
• Black-and-white is still the preferred way of displaying images in many areas– Black ink is cheaper than color
– Printing with black ink is simpler and hence cheaper
– Paper for black inks is not special
• To get color to black and white, first turn into grayscale: I=0.299R+0.587G+0.114B– This formula reflects the fact that green is more representative of
perceived brightness than blue is
![Page 5: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/5.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Sample Images
![Page 6: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/6.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Threshold Dithering
• For every pixel: If the intensity < 0.5, replace with black, else replace with white– 0.5 is the threshold– This is the naïve version of the algorithm
• To keep the overall image brightness the same, you should:– 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%
• For all dithering we will assume that the image is gray and that intensities are represented as 0-1.0– If you have a 0-255 image, you can scale all the thresholds (multiply by
255)
![Page 7: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/7.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Naïve Threshold Algorithm
![Page 8: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/8.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Random Modulation
• Add a random amount to each pixel before thresholding– Typically add uniformly random amount from [-a,a]
• Pure addition of noise to the image– As stated above, we are adding uniformly random noise
– For better results, add better quality noise
– For instance, use Gaussian noise
• Should use same procedure as before for choosing threshold
• Not good for black and white, but OK for more colors– Add a small random color to each pixel before finding the closest
color in the table
![Page 9: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/9.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Random Modulation
![Page 10: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/10.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Ordered Dithering
• 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 own threshold
• The thresholds can be clustered, which looks like newsprint
• The thresholds can be “random” which looks better
Threshold matrix
59812
151144
711610
133162
16
1
25.025.025.025.0
25.05.05.05.0
25.05.075.075.0
25.05.075.01
0000
0101
0010
0101
![Page 11: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/11.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Clustered Dithering
18 5 17325
15 6 2 112174912
18 19 13 24 16
1420102322
![Page 12: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/12.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Dot Dispersion
111 7610
4 14 1559812
133162
![Page 13: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/13.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Pattern Dithering
• 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
![Page 14: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/14.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Floyd-Steinberg Dithering
• 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• Propagate error to neighbors by adding some proportion of
the error to each unprocessed neighbor
e
3/16 5/16 1/16
7/16
![Page 15: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/15.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Floyd-Steinberg Dithering
![Page 16: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/16.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Color Dithering
• All the same techniques can be applied, with some modification– Below is Floyd-Steinberg: Error is difference from nearest color in
the color table, error propagation is the same
![Page 17: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/17.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Images as Signals
• We can view images as a signal - a value that changes over space
• Spatial domain: signal is given as values at points in space
• Frequency Domain: signal is given as values of frequency components
![Page 18: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/18.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Why Signal Processing?
• Reconstruction:– What happens when a monitor converts a set of points into a
continuous picture?– How do we enlarge images?
• Sampling:– How do we know how many pixels are required?
• Jaggies, Aliasing– How do we avoid jagged, pixelated lines
• Digital Signal Processing provides the tools
![Page 19: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/19.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
A Striking Example
domain same )sin( 22 ,yx
![Page 20: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/20.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Periodic Functions
• Fact: Any periodic signal can be represented as a sum of sine and cosine waves with harmonic frequencies– If one function has frequency f, then its harmonics are function with
frequency nf for integer n
• Sequence of boxes is:
xxx
k
xkxS
k
kboxes
5cos5
13cos
3
1cos
2
2
1
12
)12cos()1(
2
2
1)(
1
1
![Page 21: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/21.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Boxes as Sum of Cosines
-0.25
-0.05
0.15
0.35
0.55
0.75
0.95
1.15
-0.25
-0.05
0.15
0.35
0.55
0.75
0.95
1.15
-0.25
-0.05
0.15
0.35
0.55
0.75
0.95
1.15
-0. 25
-0. 05
0. 15
0. 35
0. 55
0. 75
0. 95
1. 15
-0. 25
-0. 05
0. 15
0. 35
0. 55
0. 75
0. 95
1. 15
![Page 22: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/22.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
General Functions
• A non-periodic function can be represented as a sum of sin’s and cos’s of (possibly) all frequencies:
• F() is the spectrum of the function f(x)– 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
deFxf xi)(
2
1)(
xixe xi sincos
![Page 23: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/23.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Fourier Transform
• F() is computed from f(x) by the Fourier Transform:
dxexfF xi )()(
![Page 24: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/24.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Example: Box Function
21 02
1 1)(
x
xxf
f
ff
fF
sinc2
sin
)(
![Page 25: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/25.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Box Function and Its Transform
-0.5
-0.3
-0.1
0.1
0.3
0.5
0.7
0.9
1.1
1.3
1.5
-0.5
-0.3
-0.1
0.1
0.3
0.5
0.7
0.9
1.1
1.3
1.5
![Page 26: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/26.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Cosine and Its Transform
-1.5
-1
-0.5
0
0.5
1
1.5
1-1
If f(x) is even, so is F()
![Page 27: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/27.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Sine and Its Transform
-1. 5
-1
-0. 5
0
0. 5
1
1. 5
1
-1
-
If f(x) is odd, so is F()
![Page 28: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/28.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Constant Function and Its Transform
The constant function only contains the 0th frequency – it has no wiggles
![Page 29: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/29.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Delta Function and Its Transform
Fourier transform and inverse Fourier transform arequalitatively the same, so knowing one direction gives you the other
![Page 30: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/30.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Shah Function and Its Transform
![Page 31: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/31.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Gaussian and Its Transform (the same)
-0. 02
0. 03
0. 08
0. 13
0. 18
-0. 02
0. 03
0. 08
0. 13
0. 182
2
2
1 x
e
![Page 32: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/32.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
• The spectrum of a functions tells us the relative amounts of high and low frequencies– Sharp edges give high frequencies
– Smooth variations give low frequencies
• A function is bandlimited if its spectrum has no frequencies above a maximum limit– sin, cos are band limited
– Box, Gaussian, etc are not
Qualitative Properties
![Page 33: 02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.](https://reader033.fdocuments.net/reader033/viewer/2022051621/5697bfd01a28abf838caaa47/html5/thumbnails/33.jpg)
02/05/2002 (C) University of Wisconsin 2002, CS 559
Functions to Images
• Images are 2D, discrete functions
• 2D Fourier transform uses product of sin’s and cos’s (things carry over naturally)
• Fourier transform of a discrete, quantized function will only contain discrete frequencies in quantized amounts– In particular, we can store the Fourier transform of a discrete image
in the same amount of space as we can store the image
• Numerical algorithm: Fast Fourier Transform (FFT) computes discrete Fourier transforms