Dip Spatial Filtering
Dip Spatial Filtering
Continuous case:
r
s T (r ) ( L 1) pr ( w)dw
0
Discrete values:
k
sk T (rk ) ( L 1) pr ( rj )
j 0
k nj L 1 k
( L 1) nj k=0,1,..., L-1
j 0 MN MN j 0
11/02/2023 1
Example: Histogram Equalization
Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096) has the
intensity distribution shown in following table.
Get the histogram equalization transformation function and give the p s(sk)
for each sk.
11/02/2023 2
Example: Histogram Equalization
0
s0 T (r0 ) 7 pr (rj ) 7 0.19 1.33 1
j 0
1
s1 T (r1 ) 7 pr (rj ) 7 (0.19 0.25) 3.08 3
j 0
s2 4.55 5 s3 5.67 6
s4 6.23 6 s5 6.65 7
s6 6.86 7 s7 7.00 7
11/02/2023 3
Example: Histogram Equalization
11/02/2023 4
11/02/2023 5
Spatial Filtering
A spatial filter consists of (a) a neighborhood, and (b) a
predefined operation
a b
g ( x, y ) w(s, t ) f ( x s, y t )
s a t b
02/11/2023 6
Spatial Filtering
02/11/2023 7
Spatial Correlation
The correlation of a filter w( x, y) of size m n
with an image f ( x, y ), denoted as w( x, y) f ( x, y)
a b
w( x, y ) f ( x, y ) w(s, t ) f ( x s, y t )
s a t b
02/11/2023 8
Spatial Convolution
The convolution of a filter w( x, y) of size m n
with an image f ( x, y ), denoted as w( x, y) f ( x, y)
a b
w( x, y ) f ( x, y ) w( s, t ) f ( x s, y t )
s a t b
02/11/2023 9
Smoothing Spatial Filters
Smoothing filters are used for blurring and for noise
reduction
02/11/2023 10
Spatial Smoothing Linear Filters
w(s, t ) f ( x s, y t )
g ( x, y ) s a t b
a b
w( s, t )
s a t b
where m 2a 1, n 2b 1.
02/11/2023 11
Two Smoothing Averaging Filter Masks
02/11/2023 12
02/11/2023 13
Example: Gross Representation of Objects
02/11/2023 14
Order-statistic (Nonlinear) Filters
— Nonlinear
02/11/2023 15
Example: Use of Median Filtering for Noise Reduction
02/11/2023 16
Sharpening Spatial Filters
► Foundation
► Laplacian Operator
02/11/2023 17
Sharpening Spatial Filters: Foundation
f
f ( x 1) f ( x)
x
2 f
f ( x 1) f ( x 1) 2 f ( x)
x 2
02/11/2023 18
02/11/2023 19
Sharpening Spatial Filters: Laplace Operator
2
f 2
f
f 2 2
2
x y
2 f
f ( x 1, y ) f ( x 1, y ) 2 f ( x, y )
x 2
2 f
f ( x, y 1) f ( x, y 1) 2 f ( x, y )
y 2
2 f f ( x 1, y ) f ( x 1, y ) f ( x, y 1) f ( x, y 1)
- 4 f ( x, y )
02/11/2023 20
Sharpening Spatial Filters: Laplace Operator
02/11/2023 21
Sharpening Spatial Filters: Laplace Operator
g ( x, y ) f ( x, y ) c 2 f ( x, y )
where,
f ( x, y ) is input image,
g ( x, y ) is sharpenend images,
c -1 if 2 f ( x, y ) corresponding to Fig. 3.37(a) or (b)
and c 1 if either of the other two filters is used.
02/11/2023 22
02/11/2023 23
Unsharp Masking and Highboost Filtering
► Unsharp masking
Sharpen images consists of subtracting an unsharp (smoothed)
version of an image from the original image
e.g., printing and publishing industry
► Steps
1. Blur the original image
2. Subtract the blurred image from the original
3. Add the mask to the original
02/11/2023 24
Unsharp Masking and Highboost Filtering
02/11/2023 25
Unsharp Masking: Demo
02/11/2023 26
Unsharp Masking and Highboost Filtering: Example
02/11/2023 27
Image Sharpening based on First-Order Derivatives
02/11/2023 28
Image Sharpening based on First-Order Derivatives
M ( x, y ) | g x | | g y |
z1 z2 z3
M ( x, y ) | z8 z5 | | z6 z5 |
z4 z5 z6
z7 z8 z9
11/02/2023 29
Image Sharpening based on First-Order Derivatives
Sobel Operators
M ( x, y ) | ( z7 2 z8 z9 ) ( z1 2 z 2 z3 ) |
z1 z2 z3 | ( z3 2 z6 z9 ) ( z1 2 z 4 z7 ) |
z4 z5 z6
z7 z8 z9
11/02/2023 30
Image Sharpening based on First-Order Derivatives
11/02/2023 31
Example
11/02/2023 32