02 Sampling
02 Sampling
Quantization Filtering
Blur Detect edges Uniform Quantization Random dither Ordered dither Floyd-Steinberg dither
Image Processing
Tom Funkhouser Princeton University COS 426, Spring 2006
Warping
Scale Rotate Warp
Pixel operations
Add random noise Add luminance Add contrast Add saturation
Combining
Composite Morph
What is an Image?
An image is a 2D rectilinear array of samples
Image Resolution
Intensity resolution
Each pixel has only Depth bits for colors/intensities
Spatial resolution
Image has only Width x Height pixels
Temporal resolution
Monitor refreshes images at only Rate Hz
Width x Height 640 x 480 1280 x 1024 3000 x 2000 6600 x 5100 Depth 8 24 12 1 Rate 30 75 24 -
Typical Resolutions
Continuous image
Digital image
Sources of Error
Intensity quantization
Not enough intensity resolution
Overview
Image representation
What is an image?
Spatial aliasing
Not enough spatial resolution
Temporal aliasing
Not enough temporal resolution
E2 =
( x, y )
(I ( x, y) P( x, y) )2
Quantization
Artifacts due to limited intensity resolution
Frame buffers have limited number of bits per pixel Physical devices have limited dynamic range
Uniform Quantization
P(x, y) = round( I(x, y) ) where round() chooses nearest value that can be represented.
P(x,y)
I(x,y)
I(x,y)
Uniform Quantization
Images with decreasing bits per pixel:
Halftoning
Classical halftoning 8 bits 4 bits 2 bits 1 bit
Notice contouring.
Dithering
Distribute errors among pixels
Exploit spatial integration in our eye Display greater range of perceptible intensities
Random Dither
Randomize quantization errors
Errors appear as noise
P(x,y)
I(x,y)
Original (8 bits) Uniform Quantization (1 bit) Floyd-Steinberg Dither (1 bit)
P(x,y)
I(x,y)
Random Dither
Ordered Dither
Pseudo-random quantization errors
Matrix stores pattern of threshholds
Original (8 bits)
i = x mod n 3 1 j = y mod n D2 = 0 2 e = I(x,y) - trunc(I(x,y)) threshold = (D(i,j)+1)/(n2+1) if (e > threshold) 0 1/5 2/5 3/5 4/5 P(x,y) = ceil(I(x, y)) else P(x,y) = floor(I(x,y)) thresholds
Ordered Dither
Bayers ordered dither matrices
4 Dn + D2 (1,1)U n
2 2
Ordered Dither
Dn =
4 Dn + D2 (2,1)U n
2 2
4 Dn + D2 (1,2)U n
2 2
4 Dn + D2 (2,2)U n
15 3 12 0 7 11 4 8 13 1 14 2 5 9 6 10
2 2
D2 =
3 0
1 2
D4 =
Original (8 bits)
Original (8 bits)
Figure 14.42 from H&B
+ + + = 1.0
Classical Halftoning
Use dots of varying size to represent intensities
Area of dots proportional to intensity in image
Halftoning
Classical halftoning
I(x,y)
P(x,y)
Classical Halftoning
Halftone patterns
Use cluster of pixels to represent intensity
Trade spatial resolution for intensity resolution
Q: In this case, would we use four halftoned pixels in place of one original pixel?
From Town Topics, Princeton Figure 14.37 from H&B
Overview
Image representation
What is an image?
What is an Image?
An image is a 2D rectilinear array of samples
Continuous image
Digital image
Sampling
Reconstruction
Image Processing
Quantization
Uniform Quantization Random dither Ordered dither Floyd-Steinberg dither
Adjusting Brightness
Filtering
Blur Detect edges
Warping
Scale Rotate Warps
Pixel operations
Add random noise Add luminance Add contrast Add saturation
Combining
Composite Morph Original Brighter
Adjusting Contrast
Compute mean luminance for all pixels
luminance = 0.30*r + 0.59*g + 0.11*b
Image Processing
Quantization
Uniform Quantization Random dither Ordered dither Floyd-Steinberg dither
Filtering
Blur Detect edges
Warping
Scale Rotate Warps
Pixel operations
Add random noise Add luminance Add contrast Add saturation Original More Contrast
Combining
Composite Morph
Image Processing
Consider reducing the image resolution
Image Processing
Image processing is a resampling problem
Resampling
Original image
Aliasing
In general:
Artifacts due to under-sampling or poor reconstruction
Spatial Aliasing
Artifacts due to limited spatial resolution
Specifically, in graphics:
Spatial aliasing Temporal aliasing
Under-sampling
Spatial Aliasing
Artifacts due to limited spatial resolution
Temporal Aliasing
Artifacts due to limited temporal resolution
Strobing Flickering
Jaggies
Temporal Aliasing
Artifacts due to limited temporal resolution
Strobing Flickering
Temporal Aliasing
Artifacts due to limited temporal resolution
Strobing Flickering
Temporal Aliasing
Artifacts due to limited temporal resolution
Strobing Flickering
Sampling Theory
When does aliasing happen?
How many samples are required to represent a given signal without loss of information? What signals can be reconstructed without loss for a given sampling rate?
Spectral Analysis
Spatial domain:
Function: f(x) Filtering: convolution
Fourier Transform
Frequency domain:
Function: F(u) Filtering: multiplication
Fourier Transform
Fourier transform:
Sampling Theorem
A signal can be reconstructed from its samples, if the original signal has no frequencies above 1/2 the sampling frequency - Shannon The minimum sampling rate for bandlimited function is called Nyquist rate
F (u ) =
f ( x)e i 2xu dx
f ( x) =
F (u )e + i 2ux du
A signal is bandlimited if its highest frequency is bounded. The frequency is called the bandwidth.
Antialiasing
Sample at higher rate
Not always possible Doesnt always solve problem
Image Processing
Real world Sample Discrete samples (pixels) Reconstruct Reconstructed function Transform Transformed function Filter Bandlimited function Sample Discrete samples (pixels) Reconstruct Display
Image Processing
Real world Sample Discrete samples (pixels) Reconstruct Reconstructed function Transform Transformed function Filter Bandlimited function Sample Discrete samples (pixels) Reconstruct Display
Image Processing
Real world Sample Discrete samples (pixels) Reconstruct Reconstructed function Transform
Continuous Function
Transformed function Filter Bandlimited function Sample Discrete samples (pixels) Reconstruct Display
Discrete Samples
Image Processing
Real world Sample Discrete samples (pixels) Reconstruct Reconstructed function Transform Transformed function Filter Bandlimited function Sample Discrete samples (pixels) Reconstruct Display
Image Processing
Real world Sample Discrete samples (pixels) Reconstruct Reconstructed function Transform
Reconstructed Function
Transformed function Filter Bandlimited function Sample Discrete samples (pixels) Reconstruct Display
Transformed Function
Image Processing
Real world Sample Discrete samples (pixels) Reconstruct Reconstructed function Transform Transformed function Filter Bandlimited function Sample Discrete samples (pixels) Reconstruct Display
Image Processing
Real world Sample Discrete samples (pixels) Reconstruct Reconstructed function Transform
Bandlimited Function
Transformed function Filter Bandlimited function Sample Discrete samples (pixels) Reconstruct Display
Discrete samples
Image Processing
Real world Sample Discrete samples (pixels) Reconstruct Reconstructed function Transform Transformed function Filter Bandlimited function Sample Discrete samples (pixels) Reconstruct Display
f max
Display
Spatial domain
Sinc ( x ) = sin x x
Convolution
Spatial domain: output pixel is weighted sum of pixels in neighborhood of input image
Pattern of weights is the filter
Filter
Convolution
Input
Output
Filter
Input
Output
Input
Output
Filter
Filter
Input
Output
Input
Output
10
Filter Filter
Input
Output
Input
Output
Filter Filter
Input
Output
Input
Output
Filter
Filter
Input
Output
Input
Output
11
Input
Output
Input
Output
Image Processing
Quantization
Uniform Quantization Random dither Ordered dither Floyd-Steinberg dither
Adjust Blurriness
Filtering
Blur Detect edges
Warping
Scale Rotate Warps
Pixel operations
Add random noise Add luminance Add contrast Add saturation
Combining
Composite Morph
Original Blur
Filter = 216 416 216
1 2 16 16 1 16 1 2 16 16 1 16
Edge Detection
Convolve with a filter that finds differences between neighbor pixels
Image Processing
Quantization
Uniform Quantization Random dither Ordered dither Floyd-Steinberg dither
Filtering
Blur Detect edges
Warping
Scale Rotate Warps
Pixel operations
Original Detect edges
1 1 1 Filter = 1 + 8 1 1 1 1
Combining
Composite Morph
12
Scaling
Resample with triangle or Gaussian filter
More on this next lecture!
Image Processing
Image processing is a resampling problem
Avoid aliasing Use filtering
Original
1/4X resolution
4X resolution
Summary
Image representation
A pixel is a sample, not a little square Images have limited resolution
13