Lecture 3
Lecture 3
Histogram
Dark:
h(rk ) nk
Light:
Normalized histogram
p(rk ) nk / MN
Low 255
contrast:
p(r ) 1
k
k 0
High
contrast:
Transformation Function
s T (r) 0 r L 1
s G(z) z
S0=1 G(z0)=0 z0=0
S1=3 G(z1)=0 z1=1
S2=5 G(z2)=0 z2=2
S3=6 G(z3)=1 z3=3
S4=6 G(z4)=2 z4=4
S5=7 G(z5)=5 z5=5
S6=7 G(z6)=6 z6=6
S7=7 G(z7)=7 z7=7
𝑟0 → 𝑧 3
𝑟1 → 𝑧 4
𝑟2 → 𝑧 5
𝑟3, 𝑟4 → 𝑧 6
𝑟5, 𝑟6, 𝑟7 →
𝑧7
Histogram Matching, Example-2
20 3
A Real Example
A Real Example – Histogram Equalization Result
A Real Example – Histogram Matching Result
Original
HE result
Local Histogram Processing
Fundamentals of Spatial Filtering
Fundamentals of Spatial Filtering
11 9 1
N(p)
g(p):
• Linear function
• Correlation
• Convolution
• Nonlinear function
• Order statistic (median)
Linear Filtering
0 0 0
* 0 1 0
0 0 0
Spatial Correlation and Convolution: 1D Signal
Extend to 2D Image
a b
w(s,t) f (x s, y t)
sat b
Weighted average
a b
w(s,t) f (x s, y t)
• Noise deduction
• reduction of “irrelevant details”
g(x, y) sat b
a b
• edge blurred
w(s, t)
sat b
Normalization factor
Smoothing Spatial Filter
1 1 1
1
* 1 1 1
9
1 1 1
Smoothing Spatial Filter
x2 y 2
1
2D Gaussian filter h(x, y) e 2σ 2
2πσ 2
*
Comparison using Different Smoothing
Filters – Different Kernels
Average Gaussian
Comparison using Different Smoothing
Filters: Different Size
smooth sharpen
http://www.bythom.com/
sharpening.htm
Original image
𝑔 𝑥, 𝑦 = 𝑓 𝑥, 𝑦 + 𝑐 ∗ 𝑒(𝑥, 𝑦)
First-order Second-order
First-order VS Second-order Derivative for
Edge Detection
Direction of change 𝜕𝑓
𝑔𝑥 𝜕𝑥
∇𝑓 = grad(𝑓) = 𝑔 =
𝑦 𝜕𝑓
𝜕𝑦
Magnitude of change (gradient image)
𝑀(𝑥, 𝑦) = 𝑚𝑎𝑔(∇𝑓)
= 𝑔2 + 𝑔2 http://en.wikipedia.org/wiki/Image_gradient
𝑥 𝑦
Edge detectors:
•Roberts cross – fast
while sensitive to noise
• Sobel - smooth
Laplacian for Image Sharpening
Laplacian for Image Sharpening
Image Sharpening