0% found this document useful (0 votes)
139 views

Fundamentals of Spatial Filtering: Outline of The Lecture

This document discusses spatial filtering of images. It introduces linear spatial filters that can be used for smoothing or sharpening images by operating on pixel neighborhoods. Spatial filtering involves applying a filter mask over an image to compute the sum of products at each location. Correlation is moving a filter mask over an image, while convolution additionally rotates the filter first. Both can be represented using vector operations, with correlation yielding the response as the dot product of the filter coefficients and image pixel values within the filter region.

Uploaded by

Syeda
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
139 views

Fundamentals of Spatial Filtering: Outline of The Lecture

This document discusses spatial filtering of images. It introduces linear spatial filters that can be used for smoothing or sharpening images by operating on pixel neighborhoods. Spatial filtering involves applying a filter mask over an image to compute the sum of products at each location. Correlation is moving a filter mask over an image, while convolution additionally rotates the filter first. Both can be represented using vector operations, with correlation yielding the response as the dot product of the filter coefficients and image pixel values within the filter region.

Uploaded by

Syeda
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Dr.

Qadri Hamarsheh

Fundamentals of spatial Filtering


Outline of the Lecture
 Introduction.
 Spatial Correlation and convolution.
 Vector Representation of linear filtering

Introduction
Filters in frequency domain:
 Lowpass filter that passes low frequencies: used for smoothing (blurring) on the
image.
 Highpass filter that passes high frequencies: used for sharpening the image.
 Bandpass filter.
Filters in spatial domain:
 Spatial filters used different masks (kemels, templates or windows).
 There is a one-to-one correspondence between linear spatial filters and filters in
frequency domains.
 Spatial filters can be used for linear and nonlinear filtering. (Frequency domain filters
just for linear filtering).
 The mechanics of spatial filtering spatial filters consists of:
1. Neighbourhood (small rectangle).
2. Predefined operation that is performed on the image pixel.

Origin
(x, y)

3*3 neighbourhoods of
(x,y)
Image f spatial domain

Figure 1
 Filtering creates new pixel with coordinates equal to the coordinates of the centre of
the neighbourhood, and whose value is the result of the filtering operation.
o If the operation performed on the image pixel is linear, then the filter is called
a linear spatial filter, otherwise, the filter is nonlinear.
o Figure 1 presents the mechanics of linear spatial filtering using a 3*3
neighborhood.
o the response (output) ( , ) of the filter at any point ( , ) in the image is the
sum of products of the filter coefficients and the image pixels values:
Dr. Qadri Hamarsheh
( , )= (− , − ) ( − , − ) + (− , ) ( − , ) +
… + ( , ) ( , ) +. . . + ( , ) ( + , + )
Observe that the center coefficient of the filter, ( , ) aligns with the pixel at
location( , ).
General mask of size ∗ :
Assume that
= +
and
= +
(where , are positive integers).
(Odd filters)
In general, linear spatial filtering of an image of size ∗ with a filter of size ∗ is
given by the expression:

( , ) = ( , ). ( + , + )

Where and are varied so that each pixel in visits every pixel in .

Image origin Image pixels


W(-1,-1) W(-1,0) W(-1,1)
W(0,-1) W(0,0) W(0,1)
W(1,-1) W(1,0) W(1,1)
Filter coefficients
Filter mask F(x-1, y-1) F(x-1, y) F(x-1, y+1)

image
F(x, y-1) F(x, y) F(x, y+1)

F(x+1, y-1) F(x+1, y) F(x+1, y+1)

Pixels of image
Figure 1
‘‘Section under filter''

Spatial Correlation and convolution

 Correlation: the process of moving a filter mask over the image and computing the
sum of products at each location.
 Convolution: the same process as correlation, except that the filter is first rotated
by
Dr. Qadri Hamarsheh
Example: 1-D illustration: (figure 2)
Assume that f is a 1-D function, and w is a filter

Figure 2
Dr. Qadri Hamarsheh

Notes:
 There are parts of the functions (images) that do not overlap (the solution of this
problem is pad f with enough 0s on either side to allow each pixel in w to visit every
pixel in f.
 If the filter is of size m, we need (m-1) 0s on either side of f.
 The first value of correlation is the sum of products of f and w for the initial position
(Figure 2.c).
(The sum of product =0) this corresponds to a displacement x =0
 To obtain the second value of correlation, we shift w are pixel location to the right
(displacement x=1) and compute the sum of products (result =0).
 The first nonzero is when x=3, in this case the 8 in w overlaps the 1 in f and the
result of correlation is 8.
 The full correlation result (figure 2.g) -12 values of x
 To work with correlation arrays that are the same size as f, in this case, we can crop
the full correlation to the size of the original function. (Figure 2.h).
 The result of correlation is a copy of w, but rotated by
 The correlation with a function with a discrete unit impulse yields a rotated version of
the function at the location of the impulse.
 The convolution with a function with a discrete unit impulse yields a copy of that
function at the location of the impulse.
Correlation and convolution with images
 With a filter of size m*n, we pad the image with a minimum of m-1 rows of 0s at
the top and the bottom, and n-1 columns of 0s on the left and right.
 If the filter mask is symmetric, correlation and convolution yield the same result.
Summary:
 Correlation of a filter w(x, y) of size m ∗ n with an image f(x, y) denoted as
a b
W(x, y) °f(x, y) = w(s, t)f(x + s, y + t)
s=−a t=−b
 In similar manner, the convolution of w(x, y) and f(x, y) denoted by
w(x, y) ∗ f(x, y) is given by:

W(x, y) ∗ f(x, y) = w(s, t)f(x − s, y − t)

Where the minus sign on the right flip (rotate by )


(We can flip and shift either f or w)

4
Dr. Qadri Hamarsheh

Vector Representation of linear filtering:


 Correlation

= + + ⋯+ = = Z

 R- the response of a mask


 – the coefficients of an m ∗ n filter
 – the corresponding image intensities encompassed by the filter
 Convolution
We simply rotate the mask by
Example: The general 3*3 mask equation:

= + + ⋯+ = = Z

Where:
and are g-dimensional vectors (mask and image)
Dr. Qadri Hamarsheh
Another representation of 3*3 filter mask

Example of filters masks

You might also like