Digital Image Processing
COSC 6380/4393
Lecture – 5
Sept. 6th, 2022
Pranav Mantini
Slides from Dr. Shishir K Shah and Frank (Qingzhong) Liu
Review: IMAGING Formation
• Image formation (pinhole, add lens)
light source
• Image acquisition (point source)
emitted rays
image
object
lens
reflected
rays
focal
sensing length
plate,
emulsion, etc
2
Review: Sensor Response Waveform
Weeks 1 & 2 3
Review: Response from a raster scan
Weeks 1 & 2 4
Review: A / D CONVERSION
• For computer processing, the analog image must undergo ANALOG / DIGITAL
(A/D) CONVERSION - Consists of sampling and quantization
Review: A / D CONVERSION
• For computer processing, the analog image must undergo ANALOG / DIGITAL
(A/D) CONVERSION - Consists of sampling and quantization
Sampling
• Each video raster is converted from a continuous voltage waveform into a
sequence of voltage samples:
Spatial and Intensity Resolution
• Spatial resolution
— A measure of the smallest discernible detail in an image
— stated with line pairs per unit distance, dots (pixels) per unit distance, dots per inch
(dpi)
• Intensity resolution
— The smallest discernible change in intensity level
— stated with 8 bits, 12 bits, 16 bits, etc.
Weeks 1 & 2 7
Review: Sampling: Example
VS
169 Samples 67,600 Samples
Review: Quantization
Weeks 1 & 2 9
Resampling
• Once the image is acquired.
• How to
– Enlarge an image
– Shrink an image
– Zoom in
• Zooming Example:
– Initial image size = 500 X 500
– Required image size (= X 1.5) = 750 X 750
Geometric Transformation
0 1 2 3
0 1 0
20 120
0
1
90 10
1 2
3
Geometric Transformation
0 1 2 3
0 1 0
20 120
0
1
90 10
1 2
3
Geometric transformation for
mapping pixels.
(0,0) X 2 → (0,0)
(0,1) X 2 → (0,2)
(1,0) X 2 → (2,0)
(1,1) X 2 → (2,2)
Geometric Transformation
0 1 2 3
0 1 0 20 120
20 120
0
1
90 10
1 2 90 10
3
Geometric transformation for
mapping pixels.
(0,0) X 2 → (0,0)
(0,1) X 2 → (0,2)
(1,0) X 2 → (2,0)
(1,1) X 2 → (2,2)
Image Interpolation
• Interpolation — Process of using known data to
estimate unknown values
e.g., zooming, shrinking, rotating, and geometric correction
• Interpolation (sometimes called resampling) — an
imaging method to increase (or decrease) the number of pixels
in a digital image.
Some digital cameras use interpolation to produce a larger image than the
sensor captured or to create digital zoom
http://www.dpreview.com/learn/?/key=interpolation
Weeks 1 & 2 14
Geometric Transformation
0 1 2 3
0 1 0 20 120
20 120
0
1
90 10
1 2 90 10
3
Geometric transformation for
mapping pixels.
(0,0) X 2 → (0,0) It is difficult to interpolate and fill missing value when
(0,1) X 2 → (0,2) applying forward geometric transformation.
(1,0) X 2 → (2,0)
(1,1) X 2 → (2,2)
Geometric Transformation: Inverse lookup
0 1 2 3
0 1 0
20 120
0
1
90 10
1 2
1. Create an image of desired size
Geometric Transformation: Inverse lookup
0 1 2 3
0 1 0
20 120
0
1
90 10
1 2
1. Create an image of desired size
2. For each pixel in the new image calculate which pixel it
corresponds to in the original image
Geometric Transformation: Inverse lookup
0 1 2 3
0 1 0 Inverse mapping pixels.
(0,0) X 1/2 → (0,0)
20 120
0 (0,1) X 1/2 → (0,0.5)
1 (0,2) X 1/2 → (0,1)
(0,3) X 1/2 → (0,1.5)
90 10 …
1 2
1. Create an image of desired size
2. For each pixel in the new image calculate which pixel it
corresponds to in the original image.
Geometric Transformation: Inverse lookup
0 1 2 3
0 1 0 Inverse mapping pixels.
(0,0) X 1/2 → (0,0)
20 120
0 (0,1) X 1/2 → (0,0.5)
1 (0,2) X 1/2 → (0,1)
(0,3) X 1/2 → (0,1.5)
90 10 …
1 2
1. Create an image of desired size
2. For each pixel in the new image calculate which pixel it
corresponds to in the original image.
3. Use values from nearby pixel to guess missing values
Image Interpolation
• Interpolation — Process of using known data to
estimate unknown values
e.g., zooming, shrinking, rotating, and geometric correction
• Interpolation (sometimes called resampling) — an
imaging method to increase (or decrease) the number of pixels
in a digital image.
Some digital cameras use interpolation to produce a larger image than the
sensor captured or to create digital zoom
http://www.dpreview.com/learn/?/key=interpolation
Weeks 1 & 2 20
Nearest Neighbor
0 1 2 3
0 1 0 Inverse mapping pixels.
(0,0) X 1/2 → (0,0)
20 120
0 (0,1) X 1/2 → (0,0.5)
1 (0,2) X 1/2 → (0,1)
(0,3) X 1/2 → (0,1.5)
90 10
1 2
1. Create an image of desired size
2. For each pixel in the new image calculate which pixel it
corresponds to in the original image.
3. Use nearest pixel values
Nearest Neighbor
0 1 2 3
0 1 0 Inverse mapping pixels.
(0,0) X 1/2 → (0,0)
20 120
0 (0,1) X 1/2 → (0,0.5)
1 (0,2) X 1/2 → (0,1)
(0,3) X 1/2 → (0,1.5)
90 10
1 2
1. Create an image of desired size
2. For each pixel in the new image calculate which pixel it
corresponds to in the original image.
3. Use nearest pixel values for missing values
Interpolation: Nearest Neighbor
5 X 8 Image
3 X 3 Image
Fill in values preserving
spatial relationship
Interpolation: Nearest neighbor
Original
24
Zoom
Interpolation: Nearest neighbor
Original
25
Zoom
Interpolation (1D)
𝐼1 𝐼 𝐼2
𝑥1 𝑥 𝑥2
• Known points 𝑥1 𝑎𝑛𝑑 𝑥2 with values
• 𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛 𝑓 → ℝ
• 𝑓 𝑥1 = 𝐼1 and 𝑓 𝑥2 = 𝐼2
• How to find the value 𝐼 at point 𝑥
Linear Interpolation
𝐼1 𝐼 𝐼2
𝑥1 𝑥 𝑥2
• Underlying assumption: 𝑓is linear
Linear Interpolation
𝐼1 𝐼 𝐼2
𝑥1 𝑥 𝑥2
• Underlying assumption: 𝑓is linear
𝑓 𝑧 = 𝑎𝑧 + 𝑏
Linear Interpolation
𝐼1 𝐼 𝐼2
𝑥1 𝑥 𝑥2
• Underlying assumption: 𝑓is linear
𝑓 𝑧 = 𝑎𝑧 + 𝑏
𝑓 𝑥1 = 𝑎𝑥1 + 𝑏
𝑓 𝑥2 = 𝑎𝑥2 + 𝑏
Linear Interpolation
𝐼1 𝐼 𝐼2
𝑥1 𝑥 𝑥2
• Underlying assumption: 𝑓is linear
𝑓 𝑧 = 𝑎𝑧 + 𝑏
𝑓 𝑥1 = 𝑎𝑥1 + 𝑏
𝑓 𝑥2 = 𝑎𝑥2 + 𝑏
𝑓 𝑥2 − 𝑓 𝑥1 = 𝑎𝑥2 + 𝑏 − (𝑎𝑥1 + 𝑏)
𝐼2 − 𝐼1 = 𝑎 𝑥2 − 𝑥1
⇒ 𝐼2 − 𝐼1 ∝ (𝑥2 − 𝑥1 )
Linear Interpolation
𝐼1 𝐼 𝐼2
𝑥1 𝑥 𝑥2
𝐼2 − 𝐼1 ∝ 𝑥2 − 𝑥1
𝐼 − 𝐼1 ∝ ?
Linear Interpolation
𝐼1 𝐼 𝐼2
𝑥1 𝑥 𝑥2
𝐼2 − 𝐼1 ∝ 𝑥2 − 𝑥1
𝐼 − 𝐼1 ∝ 𝑥 − 𝑥1
Linear Interpolation
𝐼1 𝐼 𝐼2
𝑥1 𝑥 𝑥2
𝐼2 − 𝐼1 ∝ 𝑥2 − 𝑥1
𝐼 − 𝐼1 ∝ 𝑥 − 𝑥1
Dividing them,
𝐼2 − 𝐼1 𝑥2 − 𝑥1
=
𝐼 − 𝐼1 𝑥 − 𝑥1
Linear Interpolation
𝐼1 𝐼 𝐼2
𝑥1 𝑥 𝑥2
Solve for 𝐼
𝐼2 − 𝐼1 𝑥2 − 𝑥1
=
𝐼 − 𝐼1 𝑥 − 𝑥1
𝑥 − 𝑥1
(𝐼2 −𝐼1 ) = 𝐼 − 𝐼1
𝑥2 − 𝑥1
𝑥 − 𝑥1
𝐼 = 𝐼1 + (𝐼2 −𝐼1 )
𝑥2 − 𝑥1
Linear Interpolation
𝐼1 𝐼 𝐼2
𝑥1 𝑥 𝑥2
Solve for 𝐼
𝐼2 − 𝐼1 𝑥2 − 𝑥1
=
𝐼 − 𝐼1 𝑥 − 𝑥1
𝑥 − 𝑥1
(𝐼2 −𝐼1 ) = 𝐼 − 𝐼1
𝑥2 − 𝑥1
𝑥 − 𝑥1
𝐼 = 𝐼1 + (𝐼2 −𝐼1 )
𝑥2 − 𝑥1
Linear Interpolation
𝐼1 𝐼 𝐼2
𝑥1 𝑥 𝑥2
Solve for 𝐼
𝐼1 𝑥2 − 𝑥1 + (𝐼2 −𝐼1 ) 𝑥 − 𝑥1
𝐼=
𝑥2 − 𝑥1
𝐼1 𝑥2 − 𝑥 + 𝐼2 𝑥 − 𝑥1
𝐼=
𝑥2 − 𝑥1
𝐼1 𝑥2 − 𝑥 𝐼2 𝑥 − 𝑥1
𝐼= +
𝑥2 − 𝑥1 𝑥2 − 𝑥1
Example: Linear Interpolation
𝐼1 = 10 𝐼 =? 𝐼2 = 15
𝑥1 = 0 𝑥 = 0.3 𝑥2 = 1
Solve for 𝐼
Example: Linear Interpolation
𝐼1 = 10 𝐼 =? 𝐼2 = 15
𝑥1 = 0 𝑥 = 0.3 𝑥2 = 1
Solve for 𝐼
𝐼1 𝑥2 − 𝑥 𝐼2 𝑥 − 𝑥1
𝐼= +
𝑥2 − 𝑥1 𝑥2 − 𝑥1
Example: Linear Interpolation
𝐼1 = 10 𝐼 =11.5 𝐼2 = 15
𝑥1 = 0 𝑥 = 0.3 𝑥2 = 1
Solve for 𝐼
𝐼1 𝑥2 − 𝑥 𝐼2 𝑥 − 𝑥1
𝐼= +
𝑥2 − 𝑥1 𝑥2 − 𝑥1
10(1 − 0.3) 15 0.3 − 0
𝐼= +
1−0 1−0
𝐼 = 7 + 4.5 = 11.5
Bi-Linear Interpolation(2D)
Q11 = (x1, y1),
Q12 = (x1, y2),
Q21 = (x2, y1),
and Q22 = (x2, y2)
𝑓 𝑄𝑖 → 𝑖𝑛𝑡𝑒𝑛𝑠𝑖𝑡𝑦 𝑎𝑡 𝑄𝑖
Find the value at 𝑃
https://en.wikipedia.org/wiki/Bilinear_interpolation
Bi-Linear Interpolation(2D)
Q11 = (x1, y1),
Q12 = (x1, y2),
Q21 = (x2, y1),
and Q22 = (x2, y2)
Find the value at 𝑃
https://en.wikipedia.org/wiki/Bilinear_interpolation
Bi-Linear Interpolation(2D)
Q11 = (x1, y1),
Q12 = (x1, y2),
Q21 = (x2, y1),
and Q22 = (x2, y2)
Find the value at 𝑃
https://en.wikipedia.org/wiki/Bilinear_interpolation
Bi-Linear Interpolation(2D)
Q11 = (x1, y1),
Q12 = (x1, y2),
Q21 = (x2, y1),
and Q22 = (x2, y2)
Find the value at 𝑃
https://en.wikipedia.org/wiki/Bilinear_interpolation
Example
𝐼 21,14 = 162,
𝐼 21,15 = 95,
𝐼 20,14 = 91,
𝐼 20,15 = 210
𝐼 20.2, 14.5 = ?
https://en.wikipedia.org/wiki/Bilinear_interpolation
Example
𝐼 21,14 = 162,
𝐼 21,15 = 95,
𝐼 20,14 = 91,
𝐼 20,15 = 210
𝐼 20.2, 14.5 = ?
https://en.wikipedia.org/wiki/Bilinear_interpolation
Example
𝐼 21,14 = 162,
𝐼 21,15 = 95,
𝐼 20,14 = 91,
𝐼 20,15 = 210
𝐼 20.2, 14.5 = ?
https://en.wikipedia.org/wiki/Bilinear_interpolation
Example
𝐼 21,14 = 162,
𝐼 21,15 = 95,
𝐼 20,14 = 91,
𝐼 20,15 = 210
𝐼 20.2, 14.5 = ?
https://en.wikipedia.org/wiki/Bilinear_interpolation
Bilinear Interpolation
5 X 8 Image
3 X 3 Image
Bilinear Interpolation
0 1 2 3
0 1 0 Inverse mapping pixels.
(0,0) X 1/2 → (0,0)
20 120
0 (0,1) X 1/2 → (0,0.5)
1 (0,2) X 1/2 → (0,1)
(0,3) X 1/2 → (0,1.5)
90 10 …
1 2 …
1. Create an image of desired size
2. For each pixel in the new image calculate which pixel it
corresponds to in the original image.
3. Use four nearest pixel to perform bi-linear interpolation
0 1 2 3
0 1 0
20 120
0
1
90 10
1 2
0 0.5 1 3
20 120
0
Inverse mapping pixels.
0.5 (1,1) X 1/2 → (0.5,0.5)
1
90 10
Nearest neighbor Interpolation
Bilinear Interpolation
Nearest neighbor Interpolation
Bilinear Interpolation
Bilinear: Alternative algorithm
• An alternative way to write the solution to the interpolation
problem is
• Not linear but quadratic
Image Interpolation:
Bicubic Interpolation
• The intensity value assigned to point (x,y) is obtained by the
following equation
3 3
f3 ( x, y ) = aij x y i j
i =0 j =0
• The sixteen coefficients are determined by using the sixteen
nearest neighbors.
Weeks 1 & 2 57
Bilinear Interpolation
Bicubic Interpolation