Filtering Basics
Filtering Basics
Introduction
What is computer vision?
The analysis of digital images by a computer
Low-Level
sharpening
blurring
7
Low-Level
Canny
original image
edge image
Mid-Level
ORT
data
structure
circular arcs and line segments
8
edge image
Mid-level
K-means
clustering
(followed by
connected
component
analysis)
Low- to High-Level
low-level
edge image
mid-level
high-level
consistent
line clusters
Building Recognition
10
System Architecture
System Architecture
Typical computer vision system
involves three components,
1. Scene under study
2. Sensing device that can be used to
analyze the scene (used to collect
data from the scene)
System Architecture
3.
0
0
1
0
0
1
0
0
1
95
92
93
92
94
0
1
96
93
93
93
95
1
1
94
93
94
93
95
0
0
93
92
92
93
96
0
0
92
92
93
93
95
binary image
gray-scale (or gray-tone) image
color image
multi-spectral image
range image
labeled image
14
Spatial Filtering
Image filtering
Image filtering
What is an image?
Images as functions
We can think of an image as a function,
f, from R2 to R:
f( x, y ) gives the intensity at position ( x, y )
Realistically, we expect the image only to
be defined over a rectangle, with a finite
range:
f: [a,b]x[c,d] [0,1]
Images as functions
A color image is just three functions pasted
together. We can write this as a vector-valued
function:
r ( x, y )
f ( x, y ) g ( x, y )
b( x, y )
Images as functions
Filtering noise
How can we smooth away noise in
an image?
0
100
130
110
120
110
110
90
100
90
100
130
100
90
130
110
120
100
130
110
120
90
110
80
120
100
Mean filtering
Mean filtering
0
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
10
20
30
30
30
20
10
20
40
60
60
60
40
20
30
60
90
90
90
60
30
30
50
80
80
90
60
30
30
50
80
80
90
60
30
20
30
50
50
60
40
20
10
20
30
30
30
30
20
10
Cross-correlation filtering
Lets write this down as an equation. Assume
the averaging window is (2k+1)x(2k+1):
Mean kernel
Whats the kernel for a 3x3 mean
filter?
0
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
90
Mean of neighborhood
Gaussian filtering
A Gaussian kernel gives less weight
to pixels further from the center of
the window
Linear vs Non-Linear
Spatial Filtering Methods
A filtering method is linear when the output is a
weighted sum of the input pixels.
Correlation (contd)
Often used in applications
where we need to measure
the
similarity
between
images or parts of images
(e.g., template matching).
Convolution
Similar to correlation except that the mask is
first flipped both horizontally and vertically.
K /2
K /2
w( s, t ) f (i s, j t )
s K /2 t K / 2
Image gradient
How can we differentiate a digital
image F[x,y]?
Option 1: reconstruct a continuous
image, f, then take gradient
Option 2: take discrete derivative (finite
difference)
Image gradient
original
Why does
this work?
smoothed original
(scaled by 4, offset +128)
Gaussian
delta function
Laplacian of Gaussian
(2nd derivative operator)
More on filters
Cross-correlation/convolution is useful for, e.g.,
Blurring
Sharpening
Edge Detection
Interpolation
Convolution has a number of nice properties
Commutative, associative
Convolution corresponds to product in the Fourier domain
More sophisticated filtering techniques can often yield superior results for
these and other tasks:
Polynomial (e.g., bicubic) filters
Steerable filters
Median filters
Bilateral Filters
Filters
We will mainly focus on two types of
filters:
Smoothing (low-pass)
Sharpening (high-pass)
Gaussian
smoothed image
2nd derivative
of Gaussian
sharpened image
Smoothing Filters
Averaging
Gaussian
Median filtering (non-linear)
3x3
15x15
5x5
25x25
7x7
15 x 15 averaging
image thresholding
= 1.4
mask size is
a function of :
=3
Averaging
Gaussian
averaging
median
filtering
Sharpening Filters
Unsharp masking
High Boost filter
Gradient (1st derivative)
Laplacian (2nd derivative)
=
(after contrast
enhancement)
(A-1)
A=1.4
A=1.9
Sharpening Filters:
Derivatives
Taking the derivative of an image
results in sharpening the image.
The derivative of an image (i.e., 2D
signal) can be computed using the
gradient.
Laplacian
The Laplacian (2nd derivative) is defined as:
(dot product)
Approximate
2nd derivatives:
Laplacian (contd)
Laplacian Mask
Example: Laplacian vs
Gradient
Laplacian
Sobel