Professional Documents
Culture Documents
Hakan Bilen
University of Edinburgh
Computer Graphics
Fall 2017
This week
• What is an image?
• What is a digital image?
• Image processing
• Point operations
• Linear operations (anti-aliasing)
• Fourier transformation
• Global optimization (data-driven) based methods
What is an image?
𝐼 𝑥, 𝑦 ~illumination 𝑥, 𝑦 × reflectance 𝑥, 𝑦
0 <illumination 𝑥, 𝑦 < inf
0 < reflectance 𝑥, 𝑦 < 1
The dynamic range of an image is the total number of distinctive pixel values that
occur in the image.
10-6 106
Picture
0 to 255
10-6 106
Picture
0 to 255
Slide credits: Alyosha Efros
Image credits: shutterbug.com
Quantization I
Quantization II
What is image processing?
How can I look better in photos?
Definition: to preprocess the image and convert it into a form suitable for further
analysis (Szelisky)
read an image, process it and write the result
>>convert chinese_chess.jpg -
contrast chinese_contrast.png
𝑠 = 𝑐 ⋅ 𝑙𝑜𝑔(1 + 𝑟)
Log
Point Processing
Power-law transformations
γ
𝑠 = 𝑐𝑟
𝛾=3
𝛾 =4 𝛾 =5
Negative
Contrast Stretching
Image Histograms
Cumulative Histograms
𝑟
𝑠 = 𝑇 𝑟 = න 𝑝𝑟 𝑤 𝑑𝑤
0
Histogram Equalization
Color Transfer [Reinhard, et al, 2001]
Erik Reinhard, Michael Ashikhmin, Bruce Gooch, Peter Shirley, Color Transfer between
Images. IEEE Computer Graphics and Applications, 21(5), pp. 34–41. September 2001.
Limitations of Point Processing
low high
frequencies
Sampled representations
https://www.youtube.com/watch?v=ByTsISFXUoY
Aliasing in video
𝑢=𝑘 𝑣=𝑘
𝐺(𝑥, 𝑦) = 𝐻 𝑢, 𝑣 𝐹(𝑥 + 𝑢, 𝑦 + 𝑣)
𝑢=−𝑘 𝑣=−𝑘
𝐺 = 𝐻⨂𝐹
Can think of as a “dot product” between local neighborhood and kernel for each pixel
In 2D: box filter
h( , )
1 1 1
1 1 1
1 1 1
h( ,) 1 1 1
1 1 1
f (,) g (,)
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0
0 0
0 0
0 90
90 0
0 90
90 90
90 90
90 0
0 0
0
0
0 0
0 0
0 90
90 90
90 90
90 90
90 90
90 0
0 0
0
0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0
0
0 0
0 90
90 0
0 0
0 0
0 0
0 0
0 0
0 0
0
0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0
g (u , v) h( x, y ) f (u x, v y )
x, y Credit: S. Seitz
Image filtering 1 1 1
h( ,) 1 1 1
1 1 1
f (,) g (,)
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
g (u , v) h( x, y ) f (u x, v y )
x, y Credit: S. Seitz
Image filtering 1 1 1
h( ,) 1 1 1
1 1 1
f (,) g (,)
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
g (u , v) h( x, y ) f (u x, v y )
x, y Credit: S. Seitz
Image filtering 1 1 1
h( ,) 1 1 1
1 1 1
f (,) g (,)
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
g (u , v) h( x, y ) f (u x, v y )
x, y Credit: S. Seitz
Image filtering 1 1 1
h( ,) 1 1 1
1 1 1
f (,) g (,)
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
g (u , v) h( x, y ) f (u x, v y )
x, y Credit: S. Seitz
Image filtering 1 1 1
h( ,) 1 1 1
1 1 1
f (,) g (,)
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
?
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
g (u , v) h( x, y ) f (u x, v y )
x, y Credit: S. Seitz
Image filtering 1 1 1
h( ,) 1 1 1
1 1 1
f (,) g (,)
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
?
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0 50
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
g (u , v) h( x, y ) f (u x, v y )
x, y Credit: S. Seitz
Image filtering 1 1 1
1 1 1
1 1 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10
0 0 0 90 90 90 90 90 0 0 0 20 40 60 60 60 40 20
0 0 0 90 90 90 90 90 0 0 0 30 60 90 90 90 60 30
0 0 0 90 90 90 90 90 0 0 0 30 50 80 80 90 60 30
0 0 0 90 0 90 90 90 0 0 0 30 50 80 80 90 60 30
0 0 0 90 90 90 90 90 0 0 0 20 30 50 50 60 40 20
0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 30 20 10
0 0 90 0 0 0 0 0 0 0 10 10 10 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
Credit: S. Seitz
Box Filter
h( , )
What does it do?
• Replaces each pixel with an 1 1 1
average of its neighborhood
1 1 1
• Achieve smoothing effect 1 1 1
(remove sharp features)
1 1 1
1 1 1 =
1 1 1
Source: D. Lowe
Practice with linear filters
?
0 0 0
0 1 0
0 0 0
Original
Source: D. Lowe
Practice with linear filters
0 0 0
0 1 0
0 0 0
Original Filtered
(no change)
Source: D. Lowe
Practice with linear filters
?
0 0 0
1 0 0
0 0 0
Original
Source: D. Lowe
Practice with linear filters
0 0 0
1 0 0
0 0 0
Source: D. Lowe
Other filters 1 0 -1
2 0 -2
1 0 -1
Sobel
Vertical Edge
(absolute value)
Other filters
1 2 1
0 0 0
-1 -2 -1
Sobel
Horizontal Edge
(absolute value)
Back to the box filter
Moving Average
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0 𝐻(𝑥, 𝑦)
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
𝐹(𝑢, 𝑣)
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 90 90 90 90 90 0 0
1 2 1
0 0 0 90 90 90 90 90 0 0 1 2 4 2
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0 16 1 2 1
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0 𝐻(𝑥, 𝑦)
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
2 2
𝐹(𝑢, 𝑣) 1 (𝑥 + 𝑦 )
ℎ 𝑖, 𝑗 = 2
(− 2
)
2𝜋𝜎 2𝜎
σ = 2 with 30 x 30 σ = 5 with 30 x 30
kernel kernel
Source: K. Grauman
Gaussian filters
•The Gaussian function has infinite support, but discrete filters use finite kernels
Source: K. Grauman
Practical matters
1/8
1/4
1/2
Throw away every other row and column to create a 1/2 size
image
- called image sub-sampling
Slide by Steve Seitz
Image sub-sampling
G 1/8
G 1/4
Gaussian 1/2
Solution: filter the image, then subsample
• Filter size should double for each ½ size reduction. Why?
Slide by Steve Seitz
Subsampling with Gaussian filtering
G 1/8
G 1/4
Gaussian 1/2
Solution: filter the image, then subsample
• Filter size should double for each ½ size reduction. Why?
• How can we speed this up? Slide by Steve Seitz
Multi-resolution Representations
Image Pyramids
filter mask
Repeat
• Filter
• Subsample
Until minimum resolution reached
• can specify desired number of levels (e.g., 3-level pyramid)
The whole pyramid is only 4/3 the size of the original image!
Slide by Steve Seitz
What are they good for?