02 Sampling Quantization Interpolation
02 Sampling Quantization Interpolation
Technology (NUST)
School of Electrical Engineering and Computer Science
(SEECS)
1 Khawar Khurshid
Sampling
Quantization
Interpolation
2 Khawar Khurshid
Sampling and Quantization
Sampling:
Digitization of the spatial coordinates (x,y)
Quantization:
Digitization in amplitude (also known as gray
level quantization)
4 Khawar Khurshid
Sampling
5 Khawar Khurshid
Quantization – (Example)
50
For Rs. 3 Return 5 45
Actual change
7 Khawar Khurshid
Quantization – (Example)
8 Khawar Khurshid
Quantization – (Example)
16 million colors
16 colors
9 Khawar Khurshid
Sampling and Quantization
Pixel Grid
10
Khawar Khurshid
Sampling and Quantization
11
Khawar Khurshid
Sampling and Quantization
12
Khawar Khurshid
Sampling and Quantization
13 Khawar Khurshid
Interpolation
14 Khawar Khurshid
Interpolation
Why?
• Changing Perspective
• Rotation
• Resizing
• Warping
15
Khawar Khurshid
Nearest Neighbor Replacement
1 0 1
1 1 0 1 1 0
1 0 1
1 0 1
16
Khawar Khurshid
Nearest Neighbor Replacement
1 1 0 0 0 1 1
1 1 0 0 0 1 1
1 0 1 1 1 1 1 1 0 0
1 1 0 1 1 1 1 1 0 0
1 0 1 1 1 1 1 1 0 0
1 1 0 0 0 1 1
1 1 0 0 0 1 1
17
Khawar Khurshid
1-D Interpolation
18
Khawar Khurshid
1-D Interpolation
19
Khawar Khurshid
1-D Interpolation
20
Khawar Khurshid
1-D Interpolation
21
Khawar Khurshid
1-D Interpolation
Degree Polynomial How it looks Req. Pts.
Zero
f(x) = 0 None
Polynomial
horizontal line
0 f(x) = a0 with y-intercept 1
a0
an oblique line
1 (Linear) f(x) = a0 + a1x with y-intercept 2
a0 and slope a1
2 Parabola
f(x) = a0 + a1x + a2x2 3
(Quadratic)
4
f(x) = a0 + a1x + a2x2+
3 (Cubic) Spline
a3x3
• Equation of a line
y1 y0
y x x0 y0
x1 x0
• Key Points:
24
Khawar Khurshid
Interpolation
Nearest Neighbor
Bi-Linear
25
Khawar Khurshid
Interpolation
215
128
26
Khawar Khurshid
Interpolation
27
Khawar Khurshid
Interpolation – (Comparison)
28
Khawar Khurshid
Interpolation – (Comparison)
Original
Image
29
Khawar Khurshid
Interpolation – (Comparison)
30
Khawar Khurshid
Interpolation – (Comparison)
31
Khawar Khurshid
Interpolation – (Non Integer)
Zoom in on a
section for a
closer look at
the process
Example:
resize to 3/7
of the original
32
Khawar Khurshid
Interpolation – (Non Integer)
3/7 resize
Zoom in for a
better look
33
Khawar Khurshid
Interpolation – (Non Integer)
3/7 resize
Outlined in
blue: 7x7
pixel squares
34
Khawar Khurshid
Interpolation – (Non Integer)
3/7 resize
In yellow: 3 pixels
for every 7 rows,
3 pixels for every
7 cols.
35
Khawar Khurshid
Interpolation – (Non Integer)
3/7 resize
Keep the
highlighted
pixels…
36
Khawar Khurshid
Interpolation – (Non Integer)
3/7 resize
… don’t keep
the others.
37
Khawar Khurshid
Interpolation – (Non Integer)
3/7 resize
38
Khawar Khurshid
Interpolation – (Non Integer)
3/7 resize
39
Khawar Khurshid
Interpolation – (Non Integer)
40
Khawar Khurshid
Interpolation – (Non Integer)
Original
image
Detail of
resized image
Resize to 3/7 of
the original dims.
41
Khawar Khurshid
Interpolation – (Non Integer)
7/3 resize
Original
image
Pixels spread out … then filled in.
for a 7/3 resize …
42
Khawar Khurshid
Interpolation – (Non Integer)
7/3 resize
Original
image Detail
43
Khawar Khurshid
Interpolation – (Non Integer)
7/3 resize
3x3 blocks
distributed over
7x7 blocks
44
Khawar Khurshid
Interpolation – (Non Integer)
7/3 resize
45
Khawar Khurshid
Interpolation – (Non Integer)
7/3 resize
46
Khawar Khurshid
Interpolation – (Non Integer)
Original
image
7/3 resized
47
Khawar Khurshid
Interpolation
• Non-adaptive algorithms
– Examples
• nearest neighbour, bilinear, bicubic, spline etc.
– Depending on their complexity, these use different number of 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.
• Adaptive algorithms
48
Khawar Khurshid
End
Sampling, Quantization,
Interpolation
49 Khawar Khurshid