KEMBAR78
Spatial Filters (Digital Image Processing) | PPTX
Unit 3-Image Enhancement
Spatial Filters
Lecture By
Kalyan Acharjya
kalyan5.blogspot.in
Lecture No 14
1
Disclaimer
 This PPT contents are copied from various
publicly available sources and all images are
copyright of the respective original owner.
 This is used for academic purpose only.
2
Spatial Filtering Methods
(or Mask Processing Methods)
output image
3
Spatial Filtering (cont’d)
 Filters are classified as:
 Low-pass (i.e., preserve low frequencies)
 High-pass (i.e., preserve high frequencies)
 Band-pass (i.e., preserve frequencies within a band)
 Band-reject (i.e., reject frequencies within a band)
4
Spatial Filtering (cont’d)
 Need to define:
 A neighborhood (or mask)
 An Mask Operation
•Typically, the neighborhood
is rectangular and its size is
much smaller than that of
f(x,y) - e.g., 3x3 or 5x5
5
Operation:
Filtered
Image
w(i,j)
f(i,j)
g(i,j)
A filtered image is generated as the center of the mask moves to
every pixel in the input image.
6
Spatial filtering - Operation
output image
Example: weighted sum of input pixels.
mask
weights:
7
Handling Pixels Close to Boundaries
Pad With Zeroes
or
0 0 0 ……………………….0
000……………………….0
8
Linear vs Non-Linear
Spatial Filtering Methods
 A filtering method is linear when the output is a weighted sum
of the input pixels.
 Methods that do not satisfy the above property are called
non-linear.
 e.g.,
9
Spatial Filters
 We will mainly focus on two types of filters:
 Smoothing (low-pass)
 Sharpening (high-pass)
10
Smoothing Filters (low-pass)
 Useful for reducing noise and eliminating
small details.
 The elements of the mask must be positive.
 Sum of mask elements is 1 (after normalization).
Gaussian
11
Smoothing filters – Example
Smoothed ImageInput Image
12
Sharpening Filters (high-pass)
 Useful for highlighting fine details.
 The elements of the mask contain both positive
and negative weights.
 Sum of mask elements is 0.
1st derivative
of Gaussian
2nd derivative
of Gaussian
13
Sharpening Filters - Example
 Warning: the results of sharpening might contain negative
values (i.e., re-map them to [0, 255])
Sharpened ImageInput Image
(for better visualization, the original
image is added to the sharpened image)
14
Common Smoothing Filters
 Averaging
 Gaussian
 Median filtering (non-linear)
15
Smoothing Filters: Averaging
Un-weighted
16
3 3 0 1 1
4 5 4 0 2
2
3 4 0 1
1
5 6 7 1
1 0 2 3 5
4 5 6 7 0
1 1 1
1 1 1
1 1 1Input Image
Mask
Smoothing Filters: Averaging
(cont’d)
 Mask size determines the degree of smoothing (loss of detail).
3x3 5x5 7x7
15x15 25x25
original
17
Image Smoothing
18
Smoothing filters: Gaussian
 The weights are samples of a 2D Gaussian
function:
mask size is
a function of σ:
σ = 1.4
19
Smoothing filters: Gaussian
(cont’d)
• σ controls the amount of smoothing
• As σ increases, more samples must be obtained to represent the Gaussian
function accurately.
σ = 3
20
Smoothing filters: Gaussian
(cont’d)
21
Averaging vs. Gaussian Smoothing
Averaging
Gaussian
22
Smoothing Filters: Median Filtering (cont’d)
 Replace each pixel by the median in a
neighborhood around the pixel.
 The size of the neighborhood controls the
amount of smoothing.
23
Smoothing Filters: Median Filtering
(non-linear)
 Very effective for removing “salt and pepper” noise (i.e., random
occurrences of black and white pixels).
Averaging
Median
Filtering
24
Original Image Image with Noise
Common Sharpening Filters
 Unsharp masking
 High Boost filter
 Gradient (1st derivative)
 Laplacian (2nd derivative)
25
Sharpening Filters: Un sharp Masking
 Obtain a sharp image by subtracting a low
pass filtered (i.e., smoothed) image from the
original image:
- =
(after contrast
enhancement)
26
Sharpening Filters: High Boost
 Image sharpening emphasizes edges but
details are lost.
 High boost filter: Amplify input image, then
subtract a Low pass image.
(A-1) + =
27
Sharpening Filters: High Boost (cont’d)
 If A=1, we get unsharp masking.
 If A>1, part of the original image is added
back to the high pass filtered image.
One way to implement
high boost filtering is using
the masks below
High boost
28
Sharpening Filters: High Boost (cont’d)
A=1.4 A=1.9
29
Sharpening Filters: Derivatives
 Taking the derivative of an image results in
sharpening the image.
 The derivative of an image (i.e., 2D function)
can be computed using the gradient.
30
How do we choose the mask weights?
 Typically, by sampling certain functions:
Gaussian
1st derivative
of Gaussian
2nd derivative
of Gaussian
31
First and Second Derivative
32
Gradient (cont’d)
 Gradient magnitude: provides information
about edge strength.
 Gradient direction: perpendicular to the
direction of the edge.
33
Derivative Results and Laplacian:
34
Reminder: Assignment
Online Submission Due Date 10 Oct 2018
1. Comments on Role of Digital Image Processing in
Modern Imaging Based Medical Treatments.
2. Explain your view on Importance of Image
Understanding in Recent Computer Vision Applications
Assignment Submission link is available at kalyan5.blogspot.in
OR
You can directly visit at http://bit.do/dipr_jnu
35
Any Questions?
Thank You
36

Spatial Filters (Digital Image Processing)

  • 1.
    Unit 3-Image Enhancement SpatialFilters Lecture By Kalyan Acharjya kalyan5.blogspot.in Lecture No 14 1
  • 2.
    Disclaimer  This PPTcontents are copied from various publicly available sources and all images are copyright of the respective original owner.  This is used for academic purpose only. 2
  • 3.
    Spatial Filtering Methods (orMask Processing Methods) output image 3
  • 4.
    Spatial Filtering (cont’d) Filters are classified as:  Low-pass (i.e., preserve low frequencies)  High-pass (i.e., preserve high frequencies)  Band-pass (i.e., preserve frequencies within a band)  Band-reject (i.e., reject frequencies within a band) 4
  • 5.
    Spatial Filtering (cont’d) Need to define:  A neighborhood (or mask)  An Mask Operation •Typically, the neighborhood is rectangular and its size is much smaller than that of f(x,y) - e.g., 3x3 or 5x5 5
  • 6.
    Operation: Filtered Image w(i,j) f(i,j) g(i,j) A filtered imageis generated as the center of the mask moves to every pixel in the input image. 6
  • 7.
    Spatial filtering -Operation output image Example: weighted sum of input pixels. mask weights: 7
  • 8.
    Handling Pixels Closeto Boundaries Pad With Zeroes or 0 0 0 ……………………….0 000……………………….0 8
  • 9.
    Linear vs Non-Linear SpatialFiltering Methods  A filtering method is linear when the output is a weighted sum of the input pixels.  Methods that do not satisfy the above property are called non-linear.  e.g., 9
  • 10.
    Spatial Filters  Wewill mainly focus on two types of filters:  Smoothing (low-pass)  Sharpening (high-pass) 10
  • 11.
    Smoothing Filters (low-pass) Useful for reducing noise and eliminating small details.  The elements of the mask must be positive.  Sum of mask elements is 1 (after normalization). Gaussian 11
  • 12.
    Smoothing filters –Example Smoothed ImageInput Image 12
  • 13.
    Sharpening Filters (high-pass) Useful for highlighting fine details.  The elements of the mask contain both positive and negative weights.  Sum of mask elements is 0. 1st derivative of Gaussian 2nd derivative of Gaussian 13
  • 14.
    Sharpening Filters -Example  Warning: the results of sharpening might contain negative values (i.e., re-map them to [0, 255]) Sharpened ImageInput Image (for better visualization, the original image is added to the sharpened image) 14
  • 15.
    Common Smoothing Filters Averaging  Gaussian  Median filtering (non-linear) 15
  • 16.
    Smoothing Filters: Averaging Un-weighted 16 33 0 1 1 4 5 4 0 2 2 3 4 0 1 1 5 6 7 1 1 0 2 3 5 4 5 6 7 0 1 1 1 1 1 1 1 1 1Input Image Mask
  • 17.
    Smoothing Filters: Averaging (cont’d) Mask size determines the degree of smoothing (loss of detail). 3x3 5x5 7x7 15x15 25x25 original 17
  • 18.
  • 19.
    Smoothing filters: Gaussian The weights are samples of a 2D Gaussian function: mask size is a function of σ: σ = 1.4 19
  • 20.
    Smoothing filters: Gaussian (cont’d) •σ controls the amount of smoothing • As σ increases, more samples must be obtained to represent the Gaussian function accurately. σ = 3 20
  • 21.
  • 22.
    Averaging vs. GaussianSmoothing Averaging Gaussian 22
  • 23.
    Smoothing Filters: MedianFiltering (cont’d)  Replace each pixel by the median in a neighborhood around the pixel.  The size of the neighborhood controls the amount of smoothing. 23
  • 24.
    Smoothing Filters: MedianFiltering (non-linear)  Very effective for removing “salt and pepper” noise (i.e., random occurrences of black and white pixels). Averaging Median Filtering 24 Original Image Image with Noise
  • 25.
    Common Sharpening Filters Unsharp masking  High Boost filter  Gradient (1st derivative)  Laplacian (2nd derivative) 25
  • 26.
    Sharpening Filters: Unsharp Masking  Obtain a sharp image by subtracting a low pass filtered (i.e., smoothed) image from the original image: - = (after contrast enhancement) 26
  • 27.
    Sharpening Filters: HighBoost  Image sharpening emphasizes edges but details are lost.  High boost filter: Amplify input image, then subtract a Low pass image. (A-1) + = 27
  • 28.
    Sharpening Filters: HighBoost (cont’d)  If A=1, we get unsharp masking.  If A>1, part of the original image is added back to the high pass filtered image. One way to implement high boost filtering is using the masks below High boost 28
  • 29.
    Sharpening Filters: HighBoost (cont’d) A=1.4 A=1.9 29
  • 30.
    Sharpening Filters: Derivatives Taking the derivative of an image results in sharpening the image.  The derivative of an image (i.e., 2D function) can be computed using the gradient. 30
  • 31.
    How do wechoose the mask weights?  Typically, by sampling certain functions: Gaussian 1st derivative of Gaussian 2nd derivative of Gaussian 31
  • 32.
    First and SecondDerivative 32
  • 33.
    Gradient (cont’d)  Gradientmagnitude: provides information about edge strength.  Gradient direction: perpendicular to the direction of the edge. 33
  • 34.
  • 35.
    Reminder: Assignment Online SubmissionDue Date 10 Oct 2018 1. Comments on Role of Digital Image Processing in Modern Imaging Based Medical Treatments. 2. Explain your view on Importance of Image Understanding in Recent Computer Vision Applications Assignment Submission link is available at kalyan5.blogspot.in OR You can directly visit at http://bit.do/dipr_jnu 35
  • 36.