You are on page 1of 28

Computer Vision

Lecture 5
2D Convolution

Let 𝐹 be the image, 𝐻 be the kernel (of size 2k+1 x 2k+1), and
𝐺 be the output image.
Linear filters: examples

0 0 0

* 0 1 0
0 0 0
=
Original Identical image
Linear filters: examples

0 0 0

* 1 0 0
0 0 0
=
Original Shifted left by 1 pixel
Convolution Filtering

Two examples of convolution filtering:

• Blurring.

• Sharpening.
Blurring

• Blur means not clear or smooth.

• Blurring is a Low-pass filtering.

• Goal: noise reduction.


Blurring

• Matrix of 1’s divided by area of kernel (box filter).

1 1 1

* 1 1 1
1 1 1
=
Original Blur
original 3x3

Noise reduced

5x5 9x9

small area
blended into
background
15x15 35x35
border
effects
Blurring

15x15 smoothing thresholding


Sharpening

• Goal: highlight fine detail in an image.

• Convolve image with sharpening kernel:

• Isharp will typically lie outside [0,1], so must


truncate or rescale.
What does blurring take away?

– =

original smoothed (5x5) detail


(This “detail extraction” operation
Let’s add it back: is also called a high-pass filter)

+α =

original detail sharpened


2D Convolution is Expensive

• 2D convolution is very useful.

• However, it is computationally expensive because convolving


an image with an nxm kernel takes nm products per pixel.
Separable convolution kernels

• A 2D convolution is separable if the kernel K can be written


as a convolution of 2 vectors.

• A separable convolution can be written as two 1D


convolutions:
Separable kernel

• What does it mean to convolve 2 vectors in 2D?

k1 -1 0 1
* 1 -1 0 1

1
= -1 0 1
K = k 1* k 2T 1 -1 0 1

k 2T K
Separable kernel
Separable kernel
Separable kernel
Separable kernel
Separable kernel
Separable kernel
Separable kernel
Separable kernel
Separable kernel
Separable kernel
Separable kernel
Separable convolution kernels

• Separable convolutions are much more efficient to compute.

• Convolving an image with an nxm kernel takes nm products


per pixel, performing the same convolution separably
requires only n+m.

You might also like