spatial filters in image processing - imperial college londontania/teaching/dip 2014/image...
TRANSCRIPT
![Page 1: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/1.jpg)
Digital Image Procesing
Spatial Filters in Image Processing
DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR) IN SIGNAL PROCESSING IMPERIAL COLLEGE LONDON
![Page 2: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/2.jpg)
Spatial filters for image enhancement
• Spatial filters called spatial masks are used for specific operations on the
image. Popular filters are the following:
Low pass filters
High boost filters
High pass filters
![Page 3: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/3.jpg)
• We have 𝑀 different noisy images:
𝑔𝑖 𝑥, 𝑦 = 𝑓 𝑥, 𝑦 + 𝑛𝑖 𝑥, 𝑦 , 𝑖 = 0,… ,𝑀 − 1
• Noise realizations are zero mean and white with the same variance, i.e.,
𝐸 𝑛𝑖 𝑥, 𝑦 = 0 and 𝑅𝑛𝑖 𝑘, 𝑙 = 𝜎𝑛𝑖2𝛿[𝑘, 𝑙] = 𝜎𝑛
2 𝛿[𝑘, 𝑙]
• We define a new image which is the average
𝑔 𝑥, 𝑦 =1
𝑀 𝑔𝑖 𝑥, 𝑦 = 𝑓 𝑥, 𝑦 +
1
𝑀 𝑛𝑖(𝑥, 𝑦)
𝑀−1
𝑖=0
𝑀−1
𝑖=0
• Notice that average is calculated across realizations.
• Problem: Find the mean and variance of the new image 𝑔 𝑥, 𝑦 .
• 𝐸{𝑔 𝑥, 𝑦 } = 𝐸{1
𝑀 𝑔𝑖(𝑥, 𝑦)} =𝑀−1𝑖=0
1
𝑀 𝐸{𝑔𝑖(𝑥, 𝑦)} = 𝑓(𝑥, 𝑦)𝑀−1𝑖=0
• 𝜎𝑔 (𝑥,𝑦)2 = 𝜎𝑓(𝑥,𝑦)
2 +1
𝑀𝜎𝑛(𝑥,𝑦)
2 =1
𝑀𝜎𝑛(𝑥,𝑦)
2
Image averaging in the case of many realizations
![Page 4: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/4.jpg)
Example: Image Averaging (number refers to realizations)
![Page 5: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/5.jpg)
Example: Image Averaging
![Page 6: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/6.jpg)
Spatial masks
![Page 7: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/7.jpg)
Local averaging spatial masks for image de-noising (smoothing)
![Page 8: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/8.jpg)
Response of 1D and 2D local averaging spatial masks
![Page 9: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/9.jpg)
Other (weighted) local averaging spatial masks
solid line shows weighted mask
dashed line shows simple averaging
![Page 10: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/10.jpg)
Example of local image averaging
![Page 11: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/11.jpg)
Example: Image Averaging
![Page 12: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/12.jpg)
Original Lena image Lena image with 10db noise
A noiseless image and its noisy version
![Page 13: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/13.jpg)
3 × 3 averaging mask 5 × 5 averaging mask
And some denoising!
![Page 14: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/14.jpg)
Median filtering
![Page 15: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/15.jpg)
Example of median filtering
![Page 16: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/16.jpg)
Comparison of local smoothing and median filtering
![Page 17: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/17.jpg)
Median versus local averaging filter response
around local step edge
![Page 18: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/18.jpg)
Median versus local averaging filter response
around local ridge edge
![Page 19: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/19.jpg)
• We use masks with positive coefficients around the centre of the mask
and negative coefficients in the periphery.
• In the mask shown below the central coefficient is +8 and its 8 nearest
neighbours are -1.
• The reversed signs are equally valid, i.e., -8 in the middle and +1 for the
rest of the coefficients.
• The sum of the mask coefficients must be zero. This leads to the
response of the mask within a constant (or slowly varying) intensity area
being zero (or very small).
1
9×
High pass filtering
![Page 20: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/20.jpg)
Example of high pass filtering
![Page 21: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/21.jpg)
High pass filtered image High pass filtered image with 10db noise
Example of high pass filtering
![Page 22: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/22.jpg)
• The goal of high boost filtering is to enhance the high frequency
information without completely eliminating the background of the image.
• We know that:
(High-pass filtered image)=(Original image)-(Low-pass filtered image)
• We define:
(High boost filtered image)=𝐴 ×(Original image)-(Low-pass filtered image)
(High boost)=(𝐴 − 1) ×(Original)+(Original)-(Low-pass)
(High boost)=(𝐴 − 1) × (Original)+(High-pass)
• As you can see, when 𝐴 > 1, part of the original is added back to the high-
pass filtered version of the image in order to partly restore the low
frequency components that would have been eliminated with standard
high-pass filtering.
• Typical values for 𝐴 are values slightly higher than 1, as for example 1.15,
1.2, etc.
High boost filtering
![Page 23: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/23.jpg)
• The resulting image looks similar to the original image with some edge
enhancement.
• The spatial mask that implements the high boost filtering algorithm is
shown below.
• The resulting image depends on the choice of 𝐴.
1
9×
• High boost filtering is used in printing and publishing industry.
High boost filtering
![Page 24: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/24.jpg)
Example of high boost filtering
![Page 25: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/25.jpg)
𝐴 = 1.15 𝐴 = 1.2
Example of high boost filtering
![Page 26: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/26.jpg)
• Edges are abrupt local changes in the image value (for example grey
level).
• Edges are of crucial important because they are related to the
boundaries of the various objects present in the image.
• Object boundaries are key feature for object detection and
identification.
• Edge information in an image is found by looking at the relationship a
pixel has with its neighborhoods.
• If a pixel’s grey-level value is similar to those around it, there is
probably not an edge at that point.
• If a pixel’s has neighbors with widely varying grey levels, it may present
an edge point.
Edge detection
![Page 27: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/27.jpg)
Abrupt versus gradual change in image intensity
![Page 28: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/28.jpg)
Step edges
Roof edge Line (ridge) edges
Type of edges
![Page 29: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/29.jpg)
depth discontinuity
surface color discontinuity
illumination discontinuity
surface normal discontinuity
Edges are caused by a variety of factots
![Page 30: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/30.jpg)
From a grey level image to an edge image (or edge map)
![Page 31: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/31.jpg)
• The gradient (first derivative) of the image around a pixel might give
information about how detailed is the area around a pixel and whether
there are abrupt intensity changes.
• The image is a 2-D signal and therefore, the gradient at a location (𝑥, 𝑦) is
a 2-D vector which contains the two partial derivatives of the image with
respect to the coordinates 𝑥, 𝑦.
𝛻𝑓 =
𝜕𝑓
𝜕𝑥𝜕𝑓
𝜕𝑦
• Edge strength is given by 𝛻𝑓 =𝜕𝑓
𝜕𝑥
2+𝜕𝑓
𝜕𝑦
21
2
or 𝛻𝑓 ≅𝜕𝑓
𝜕𝑥+𝜕𝑓
𝜕𝑦.
• Edge orientation is given by 𝜃 = 𝑡𝑎𝑛−1𝜕𝑓
𝜕𝑦/𝜕𝑓
𝜕𝑥.
How do we detect the presence of a local edge?
![Page 32: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/32.jpg)
•Edge strength is given by 𝛻f =𝜕f
𝜕x
2+𝜕f
𝜕y
21
2
or 𝛻f ≅𝜕f
𝜕x+𝜕f
𝜕y.
•Edge orientation is given by θ = tan−1𝜕f
𝜕y/𝜕f
𝜕x
Examples of edge orientations
![Page 33: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/33.jpg)
• Consider an image region of size 3 × 3 pixels. The coordinates 𝑥, 𝑦 are
shown.
• The quantity 𝑟 denotes grey level values.
• The magnitude 𝛻𝑓 =𝜕𝑓
𝜕𝑥+𝜕𝑓
𝜕𝑦 of the gradient at pixel with intensity 𝑟5
can be approximated by:
differences along 𝑥 and 𝑦 𝛻𝑓 = 𝑟5 − 𝑟6 + 𝑟5 − 𝑟8
cross-differences (along the two main diagonals)
𝛻𝑓 = 𝑟6 − 𝑟8 + 𝑟5 − 𝑟9
Spatial masks for edge detection
![Page 34: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/34.jpg)
• The magnitude 𝛻𝑓 =𝜕𝑓
𝜕𝑥+𝜕𝑓
𝜕𝑦 of the gradient at pixel with intensity 𝑟5
can be approximated by:
differences along 𝑥 and 𝑦 𝛻𝑓 = 𝑟5 − 𝑟6 + 𝑟5 − 𝑟8
cross-differences (along the two main diagonals)
𝛻𝑓 = 𝑟6 − 𝑟8 + 𝑟5 − 𝑟9
• Each of the above approximation is the sum of the magnitudes of the
responses of two masks. These sets of masks are the so called Roberts
operator.
abs{ } }+abs{ } abs{ }+abs{ }
+
Spatial masks for edge detection – Roberts operator
![Page 35: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/35.jpg)
• The magnitude 𝛻𝑓 =𝜕𝑓
𝜕𝑥+𝜕𝑓
𝜕𝑦 of the gradient at pixel with intensity 𝑟5 can
be also approximated by involving more pixels:
Roberts operator
𝛻𝑓 = (𝑟3+𝑟6 + 𝑟9) − (𝑟1 + 𝑟4 + 𝑟7) + (𝑟7+𝑟8 + 𝑟9) − (𝑟1 + 𝑟2 + 𝑟3)
Sobel operator
𝛻𝑓 = (𝑟3+2𝑟6 + 𝑟9) − (𝑟1 + 2𝑟4 + 𝑟7) + (𝑟7+2𝑟8 + 𝑟9) − (𝑟1 + 2𝑟2 + 𝑟3)
• Each of the above approximation is the sum of the magnitudes of the
responses of two masks.
abs{ }+abs{ } abs{ }+abs{ }
Spatial masks for edge detection – Prewitt and Sobel operators
![Page 36: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/36.jpg)
Example of edge detection using Prewitt
![Page 37: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/37.jpg)
Original image and its histogram
![Page 38: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/38.jpg)
Example of edge detection using Prewitt
![Page 39: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/39.jpg)
Example of edge detection using Sobel
![Page 40: Spatial Filters in Image Processing - Imperial College Londontania/teaching/DIP 2014/Image filters.pdf · Spatial Filters in Image Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR)](https://reader030.vdocuments.us/reader030/viewer/2022041010/5eb9eb8a87fc476f3f4dc134/html5/thumbnails/40.jpg)
• The second order gradient gives also information about how detailed is
the area around a pixel.
• It is defined as:
𝛻2𝑓 =𝜕2𝑓
𝜕𝑥2+𝜕2𝑓
𝜕𝑦2
• A mask that can approximate the above function is the Laplacian:
𝛻2𝑓 ≅ 4𝑟5 − (𝑟2+𝑟4 + 𝑟6 + 𝑟8)
Edge detection using second order gradient: Laplacian mask