07 - Chapter 2 - CV - Basic Techniques in Image Processing - Spatial Domain - Filtering
07 - Chapter 2 - CV - Basic Techniques in Image Processing - Spatial Domain - Filtering
COMPUTER VISION
This lecture will cover:
Basic techniques in
The above is repeated for every pixel in the original image to The filtering we have been talking about so far is referred
Computer Vision and Image Processing, [email protected]. 2024
one subtle difference
d e f u v w v*e + r*a + s*b +
t*c + u*d + w*f + x*g + v*e + z*a + y*b + x*c + w*d + u*f + t*g + s*h + r*i
g h i x y z
y*h + z*i Correlation Convolution
Original image pixels Filter
a b c r s t a b c z y x
d
g h
e f
i
u
x y
v w
z
d
g h
e f
i
w
t
v
s
u
Original Original
Filter Filter rotate 180o
image pixels image pixels
Spatial domain enhancement methods can be
Computer Vision and Image Processing, [email protected]. 2024
Spatial Filters
Pixel Operations
Computer Vision and Image Processing, [email protected]. 2024
gross detail
, ,
, ∈
Smoothing Spatial Filtering Image Smoothing Example
More effective smoothing filters can be generated by By smoothing the original image we get rid of lots of
Computer Vision and Image Processing, [email protected]. 2024
Computer Vision and Image Processing, [email protected]. 2024 the finer detail which leaves only the gross features
allowing different pixels in the neighbourhood
for thresholding
different weights in the averaging function
Weighted averaging filter
– Pixels closer to the central
pixel are more important
– Often referred to as a
weighted averaging
Original Image Thresholded Image
Smoothed Image
Averaging Filter vs. Median Filter Strange Things Happen At The
Example Edges!
Filtering is often used to remove noise from images At the edges of an image we are missing pixels
Computer Vision and Image Processing, [email protected]. 2024
e e e
Original Image Image After Image After
With Noise Averaging Filter Median Filter y Image f (x, y)
5 6 7 8 0 5 6 7 8 0 0 5 6 0
0 6 8 8 0 0 6 8 8 0 Median 5 6 8 8
zero-
filtering
5 6 15 8 padding 0 5 6 15 8 0 5 6 8 8
5 6 7 8 0 5 6 7 8 0 0 5 6 0
0 0 0 0 0 0
Spatial filters that are based on ordering the pixel Median Filter:
, ! ,
values that make up the neighbourhood operated , ∈
on by the filter
• Excellent at noise removal, without the
Useful spatial filters include smoothing effects that can occur with other
Median filter smoothing filters.
Max and min filter
Midpoint filter • Particularly good when salt and pepper noise is
Alpha trimmed mean filter present
Max Filter:
Computer Vision and Image Processing, [email protected]. 2024
Midpoint Filter:
Computer Vision and Image Processing, [email protected]. 2024
48 50 51 49 53 59 63
Good for random Gaussian and uniform noise
49 51 52 55 58 64 67
50 54 57 60 63 67 70
51 55 59 62 65 69 72
Image f (x, y) Image f (x, y)
y y
Original Image x Filtered Image x Computer Vision and Image Processing, [email protected]. 2024 The contour plays a very important role in the process of
54 52 57 55 56 52 51 image analysis
50 49 51 50 52 53 58
it is very important to ensure that the image smoothing
51 204 52 52 0 57 60
48 50 51 49 53 59 63
does not affect the sharpness of contours
49 51 52 55 58 64 67 The Kuwahara filter is an example of a filter which meets
50 54 57 60 63 67 70
these requirements
51 55 59 62 65 69 72
Image f (x, y) Image f (x, y)
This filter can be constructed for any window size
y y
Kuwahara Filter Kuwahara Filter
Image
Computer Vision and Image Processing, [email protected]. 2024
inside the filter region The key insight in the adaptive median filter is that the filter
size changes depending on the characteristics of the image
We will take a look at the adaptive median filter
Remember that filtering looks at each original pixel Level A: A1 = zmed – zmin
Computer Vision and Image Processing, [email protected]. 2024
image in turn and generates a new filtered pixel Computer Vision and Image Processing, [email protected]. 2024 A2 = zmed – zmax
First examine the following notation: If A1 > 0 and A2 < 0, Go to level B
Else increase the window size
zmin = minimum grey level in Sxy If window size ≤ repeat Smax level A
zmax = maximum grey level in Sxy Else output zmed
Level B: B1 = zxy – zmin
zmed = median of grey levels in Sxy B2 = zxy – zmax
zxy = grey level at coordinates (x, y) If B1 > 0 and B2 < 0, output zxy
Else output zmed
Smax =maximum allowed size of Sxy
Adaptive Median Filtering Adaptive Filtering Example
Computer Vision and Image Processing, [email protected]. 2024
Reduce distortion
Image corrupted by salt Result of filtering with a 7 Result of adaptive
and pepper noise with * 7 median filter median filtering with i = 7
probabilities Pa = Pb=0.25
Summary
and in particular:
– Neighbourhood operations
– The filtering process
– Smoothing filters
– Dealing with problems at image edges when using
filtering
– Correlation and convolution [email protected]