02 Sampling Quantization Interpolation
-
Upload
marshadmit -
Category
Documents
-
view
23 -
download
0
description
Transcript of 02 Sampling Quantization Interpolation
-
Advanced Digital Image Processing
Spring 14
National University of Sciences and Technology (NUST)School of Electrical Engineering and Computer Science (SEECS)
Khawar Khurshid, 20121
-
Sampling Quantization Interpolation
Khawar Khurshid, 20122
-
Sampling: Digitization of the spatial coordinates (x,y)
Quantization:Digitization in amplitude (also known as gray level quantization)
8 bit quantization: 28 =256 gray levels
(0: black, 255: white)
1 bit quantization: 21 = 2 gray levels
(0: black, 1: white)
Sampling and QuantizationSampling and QuantizationSampling and QuantizationSampling and Quantization
Khawar Khurshid, 20123
-
SamplingSamplingSamplingSampling
Khawar Khurshid, 20124
-
SamplingSamplingSamplingSampling
Khawar Khurshid, 20125
-
Quantization Quantization Quantization Quantization (Example)(Example)(Example)(Example)
Khawar Khurshid, 2012
Return change using only these notes
6
-
Quantization Quantization Quantization Quantization (Example)(Example)(Example)(Example)
Khawar Khurshid, 2012
0
5
10
15
20
25
30
35
40
45
50
0 5 10 15 20 25 30 35 40 45 50
Actual change
C
h
a
n
g
e
y
o
u
r
e
t
u
r
n
For Rs. 3 Return 5
For Rs. 7 Return 5
For Rs. 9 Return 10
For Rs. 12 Return 10
For Rs. 23 Return 25
7
-
Quantization Quantization Quantization Quantization (Example)(Example)(Example)(Example)
Khawar Khurshid, 2012
Continuous color input
D
i
s
c
r
e
t
e
c
o
l
o
r
o
u
t
p
u
t
Continuous colors mapped to a Continuous colors mapped to a finite, discrete set of colors.
8
-
Quantization Quantization Quantization Quantization (Example)(Example)(Example)(Example)
Khawar Khurshid, 2012
1
6
m
i
l
l
i
o
n
c
o
l
o
r
s
1
6
c
o
l
o
r
s
9
-
Pixel Grid
SampledReal Image Quantized Sampled & Quantized
Sampling and QuantizationSampling and QuantizationSampling and QuantizationSampling and Quantization
Khawar Khurshid, 201210
-
Sampling and QuantizationSampling and QuantizationSampling and QuantizationSampling and Quantization
Khawar Khurshid, 201211
-
Sampling and QuantizationSampling and QuantizationSampling and QuantizationSampling and Quantization
Khawar Khurshid, 201212
-
Sampling and QuantizationSampling and QuantizationSampling and QuantizationSampling and Quantization
Khawar Khurshid, 2012
256x256256 gray levels
128x128 64x64 32x32
Binary Image8 gray levels 4 gray levels16 gray levels
13
-
InterpolationInterpolationInterpolationInterpolation
Khawar Khurshid, 201214
-
Why?
Changing Perspective
Rotation
Resizing
Warping
InterpolationInterpolationInterpolationInterpolation
Khawar Khurshid, 201215
-
Simply Replicate the value from neighboring pixels.
Nearest Neighbor ReplacementNearest Neighbor ReplacementNearest Neighbor ReplacementNearest Neighbor Replacement
Khawar Khurshid, 2012
1 0 1
1 1 0
1 0 1
1 0 1
1 1 0
1 0 1
16
-
Adds blocky effect.
Nearest Neighbor ReplacementNearest Neighbor ReplacementNearest Neighbor ReplacementNearest Neighbor Replacement
Khawar Khurshid, 2012
1 0 1
1 1 0
1 0 1
1 1 0 0 0 1 1
1 1 0 0 0 1 1
1 1 1 1 1 0 0
1 1 1 1 1 0 0
1 1 1 1 1 0 0
1 1 0 0 0 1 1
1 1 0 0 0 1 1
17
-
Interpolation works by using known data to estimate values at unknown points.
1111----D InterpolationD InterpolationD InterpolationD Interpolation
Khawar Khurshid, 201218
-
Linear Interpolation: Fit a linear function piecewise between the points.
1111----D InterpolationD InterpolationD InterpolationD Interpolation
Khawar Khurshid, 201219
-
Quadratic: Fit a Quadratic Polynomial between the three points.
1111----D InterpolationD InterpolationD InterpolationD Interpolation
Khawar Khurshid, 201220
-
Fitting Polynomial to data points.
1111----D InterpolationD InterpolationD InterpolationD Interpolation
Khawar Khurshid, 201221
-
1111----D InterpolationD InterpolationD InterpolationD Interpolation
Khawar Khurshid, 2012
Degree Polynomial How it looks Req. Pts.
Zero
Polynomialf(x) = 0 None
0 f(x) = a0
horizontal line
with y-intercept
a0
1
1 (Linear) f(x) = a0 + a1x
an oblique line
with y-intercept
a0 and slope a1
2
2
(Quadratic)f(x) = a0 + a1x + a2x
2Parabola
3
3 (Cubic)f(x) = a0 + a1x + a2x
2+
a3x3
Spline
4
No. of unknowns in a polynomial of degree n-1 = n
Select n nearest known neighbours to generate n equations
Solve the linear system of equations to estimate the constants
Simply put the unknown x value and interpolate the y value22
-
Linear InterpolationLinear InterpolationLinear InterpolationLinear Interpolation
Khawar Khurshid, 2012
Equation of a line
Interpolation using Linear Polynomial y = a0 + a1x
Requires two unknowns
( ) 0001
01 yxxxx
yyy +
=
23
-
BiBiBiBi----linear Interpolationlinear Interpolationlinear Interpolationlinear Interpolation
Khawar Khurshid, 2012
Key Points:
Q11 = (x1, y1), Q12 = (x1, y2),
Q21 = (x2, y1), Q22 = (x2, y2).
Linear interpolation in the x-direction followed by linear interpolation in y-direction
24
-
InterpolationInterpolationInterpolationInterpolation
Khawar Khurshid, 2012
Nearest Neighbor
Bi-Linear
25
-
InterpolationInterpolationInterpolationInterpolation
Khawar Khurshid, 2012
215
128
26
-
InterpolationInterpolationInterpolationInterpolation
Khawar Khurshid, 201227
-
Interpolation Interpolation Interpolation Interpolation (Comparison)(Comparison)(Comparison)(Comparison)
Khawar Khurshid, 2012
Well enlarge this image by a factor of 4 Well enlarge this image by a factor of 4
via bilinear interpolation and compare it to a nearest neighbor enlargement.
via bilinear interpolation and compare it to a nearest neighbor enlargement.
28
-
Interpolation Interpolation Interpolation Interpolation (Comparison)(Comparison)(Comparison)(Comparison)
Khawar Khurshid, 2012
To better see what happens, well look at the parrots eye. To better see what happens, well look at the parrots eye.
Original ImageOriginal Image
29
-
Interpolation Interpolation Interpolation Interpolation (Comparison)(Comparison)(Comparison)(Comparison)
Khawar Khurshid, 2012
Pixel replication Pixel replication Bilinear interpolationBilinear interpolation
30
-
Interpolation Interpolation Interpolation Interpolation (Comparison)(Comparison)(Comparison)(Comparison)
Khawar Khurshid, 2012
Pixel replication Pixel replication Bilinear interpolationBilinear interpolation
31
-
Interpolation Interpolation Interpolation Interpolation (Non Integer)(Non Integer)(Non Integer)(Non Integer)
Khawar Khurshid, 2012
Zoom in on a section for a closer look at the process
Zoom in on a section for a closer look at the process
Example: resize to 3/7 of the original
Example: resize to 3/7 of the original
32
-
Interpolation Interpolation Interpolation Interpolation (Non Integer)(Non Integer)(Non Integer)(Non Integer)
Khawar Khurshid, 2012
Zoom in for a better lookZoom in for a better look
3/7 resize 3/7 resize
33
-
Interpolation Interpolation Interpolation Interpolation (Non Integer)(Non Integer)(Non Integer)(Non Integer)
Khawar Khurshid, 2012
Outlined in blue: 7x7 pixel squares
Outlined in blue: 7x7 pixel squares
3/7 resize 3/7 resize
34
-
Interpolation Interpolation Interpolation Interpolation (Non Integer)(Non Integer)(Non Integer)(Non Integer)
Khawar Khurshid, 2012
In yellow: 3 pixels for every 7 rows, 3 pixels for every 7 cols.
In yellow: 3 pixels for every 7 rows, 3 pixels for every 7 cols.
3/7 resize 3/7 resize
35
-
Interpolation Interpolation Interpolation Interpolation (Non Integer)(Non Integer)(Non Integer)(Non Integer)
Khawar Khurshid, 2012
Keep the highlighted pixels
Keep the highlighted pixels
3/7 resize 3/7 resize
36
-
Interpolation Interpolation Interpolation Interpolation (Non Integer)(Non Integer)(Non Integer)(Non Integer)
Khawar Khurshid, 2012
dont keep the others. dont keep the others.
3/7 resize 3/7 resize
37
-
Interpolation Interpolation Interpolation Interpolation (Non Integer)(Non Integer)(Non Integer)(Non Integer)
Khawar Khurshid, 2012
3/7 resize 3/7 resize
Copy them into a new image.Copy them into a new image.
38
-
Interpolation Interpolation Interpolation Interpolation (Non Integer)(Non Integer)(Non Integer)(Non Integer)
Khawar Khurshid, 2012
3/7 resize 3/7 resize
Copy them into a new image.Copy them into a new image.
39
-
Interpolation Interpolation Interpolation Interpolation (Non Integer)(Non Integer)(Non Integer)(Non Integer)
Khawar Khurshid, 2012
3/7 times the linear dimensions of the original
3/7 times the linear dimensions of the original
40
-
Interpolation Interpolation Interpolation Interpolation (Non Integer)(Non Integer)(Non Integer)(Non Integer)
Khawar Khurshid, 2012
Resize to 3/7 of the original dims.Resize to 3/7 of the original dims.
Original image
Original image
Detail of resized imageDetail of resized image
41
-
Interpolation Interpolation Interpolation Interpolation (Non Integer)(Non Integer)(Non Integer)(Non Integer)
Khawar Khurshid, 2012
Original image
Original image
Pixels spread out for a 7/3 resize Pixels spread out for a 7/3 resize
then filled in. then filled in.
7/3 resize 7/3 resize
42
-
Interpolation Interpolation Interpolation Interpolation (Non Integer)(Non Integer)(Non Integer)(Non Integer)
Khawar Khurshid, 2012
7/3 resize 7/3 resize
Detail Detail
Each 3x3 block of pixels from here
Each 3x3 block of pixels from here
is spread out over a 7x7 block here is spread out over a 7x7 block here
Original image
Original image
43
-
Interpolation Interpolation Interpolation Interpolation (Non Integer)(Non Integer)(Non Integer)(Non Integer)
Khawar Khurshid, 2012
3x3 blocks distributed over 7x7 blocks
3x3 blocks distributed over 7x7 blocks
7/3 resize 7/3 resize
44
-
Interpolation Interpolation Interpolation Interpolation (Non Integer)(Non Integer)(Non Integer)(Non Integer)
Khawar Khurshid, 2012
Empty pixels filled with color from non-empty pixel
Empty pixels filled with color from non-empty pixel
7/3 resize 7/3 resize
45
-
Interpolation Interpolation Interpolation Interpolation (Non Integer)(Non Integer)(Non Integer)(Non Integer)
Khawar Khurshid, 2012
7/3 resize 7/3 resize
Empty pixels filled with color from non-empty pixel
Empty pixels filled with color from non-empty pixel
46
-
Interpolation Interpolation Interpolation Interpolation (Non Integer)(Non Integer)(Non Integer)(Non Integer)
Khawar Khurshid, 2012
Original image
Original image
7/3 resized 7/3 resized
47
-
InterpolationInterpolationInterpolationInterpolation
Khawar Khurshid, 2012
Non-adaptive algorithms
Examples
nearest neighbour, bilinear, bicubic, spline etc.
Depending on their complexity, these use anywhere from 0 to 256 (or more) adjacent pixels when interpolating.
The more adjacent pixels they include, the more accurate they can become, but this comes at the expense of much longer processing time.
These algorithms can be used to both distort and resize a photo
Adaptive algorithms
Many of these apply a different version of their algorithm (on a pixel-by-pixel basis) when they detect the presence of an edge-- aiming to minimize unsightly interpolation artifacts in regions where they are most apparent.
These algorithms are primarily designed to maximize artifact-free detail in enlarged photos, so some cannot be used to distort or rotate an image.
48
-
EndSampling, Quantization,
Interpolation
Khawar Khurshid, 201249