SPATIAL FILTERING
ANUJ ARORA
B-TECH 2nd YEAR
ELCTRICAL ENGG.
SPATIAL FILTERING
(CONT’D)• Spatial filtering is defined by:
(1) An operation that is performed on the pixels inside the
N...
SPATIAL FILTERING
NEIGHBORHOOD
• Typically, the neighborhood is rectangular and its size
is much smaller than that of f(x,...
SPATIAL FILTERING -
OPERATION
1 1
1 1
( , ) ( , ) ( , )
s t
g x y w s t f x s y t
Assume the origin of the
mask is the cen...
• A filtered image is generated as the center of the
mask moves to every pixel in the input image.
output image
STRANGE THINGS HAPPEN
AT THE EDGES!
Origin x
y Image f (x, y)
e
e
e
e
At the edges of an image we are missing
pixels to fo...
HANDLING PIXELS CLOSE
TO BOUNDARIES
pad with zeroes
or
0 0 0 ……………………….0
000……………………….0
LINEAR VS NON-LINEAR
SPATIAL FILTERING METHODS
• A filtering method is linear when the output is a
weighted sum of the inp...
LINEAR SPATIAL FILTERING
METHODS
• Two main linear spatial filtering methods:
• Correlation
• Convolution
CORRELATION
• TO perform correlation ,we move w(x,y) in all possible
locations so that at least one of its pixels overlaps...
CONVOLUTION
• Similar to correlation except that the mask is first flipped
both horizontally and vertically.
Note: if w(x,...
CORRELATION AND
CONVOLUTION
Correlation:
Convolution:
HOW DO WE CHOOSE THE
ELEMENTS OF A MASK?
• Typically, by sampling certain functions.
Gaussian
1st derivative
of Gaussian
2...
FILTERS
• Smoothing (i.e., low-pass filters)
• Reduce noise and eliminate small details.
• The elements of the mask must b...
FILTERS
• Sharpening (i.e., high-pass filters)
• Highlight fine detail or enhance detail that has been
blurred.
• The elem...
SMOOTHING FILTERS: AVERAGING
(LOW-PASS FILTERING)
SMOOTHING FILTERS:
AVERAGING
• Mask size determines the degree of smoothing and
loss of detail.
3x3 5x5 7x7
15x15 25x25
or...
SMOOTHING FILTERS:
AVERAGING (CONT’D)
15 x 15 averaging image thresholding
Example: extract, largest, brightest objects
SMOOTHING FILTERS:
GAUSSIAN
• The weights are samples of the Gaussian function
mask size is
a function of σ :
σ = 1.4
SMOOTHING FILTERS:
GAUSSIAN (CONT’D)
• σ controls the amount of smoothing
• As σ increases, more samples must be obtained ...
SMOOTHING FILTERS:
GAUSSIAN (CONT’D)
AVERAGING VS GAUSSIAN
SMOOTHING
Averaging
Gaussian
SHARPENING FILTERS
(HIGH PASS FILTERING)
• Useful for emphasizing transitions in image intensity
(e.g., edges).
SHARPENING FILTERS
(CONT’D)
• Note that the response of high-pass filtering might be
negative.
• Values must be re-mapped ...
SHARPENING FILTERS:
UNSHARP MASKING
• Obtain a sharp image by subtracting a lowpass filtered
(i.e., smoothed) image from t...
SHARPENING FILTERS:
HIGH BOOST
• Image sharpening emphasizes edges .
• High boost filter: amplify input image, then subtra...
SHARPENING FILTERS: UNSHARP
MASKING (CONT’D)
• If A=1, we get a high pass filter
• If A>1, part of the original image is a...
SHARPENING FILTERS:
DERIVATIVES
• Taking the derivative of an image results in sharpening
the image.
• The derivative of a...
SHARPENING FILTERS:
DERIVATIVES (CONT’D)
• The gradient is a vector which has magnitude and
direction:
| | | |
f f
x y
or
...
SHARPENING FILTERS:
DERIVATIVES (CONT’D)
• Magnitude: provides information about edge strength.
• Direction: perpendicular...
SHARPENING FILTERS: GRADIENT
COMPUTATION
• Approximate gradient using finite differences:
sensitive to horizontal edges
se...
SHARPENING FILTERS: GRADIENT
COMPUTATION (CONT’D)
• We can implement and using masks:
• Example: approximate gradient at z5
SHARPENING FILTERS: GRADIENT
COMPUTATION (CONT’D)
• A different approximation of the gradient:
•We can implement and using...
SHARPENING FILTERS: GRADIENT
COMPUTATION (CONT’D)
• Example: approximate gradient at z5
EXAMPLE
f
y
f
x
SHARPENING FILTERS:
LAPLACIAN
The Laplacian (2nd derivative) is defined as:
(dot product)
Approximate
derivatives:
Spatial filtering using image processing
Spatial filtering using image processing
Spatial filtering using image processing
Spatial filtering using image processing
Spatial filtering using image processing
Spatial filtering using image processing
Upcoming SlideShare
Loading in...5
×

Spatial filtering using image processing

1,577

Published on

spatial filtering in image processing (explanation cocept of
mask),lapace filtering and filtering process of image for extract information and reduce noise

Published in: Engineering
1 Comment
5 Likes
Statistics
Notes
No Downloads
Views
Total Views
1,577
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
233
Comments
1
Likes
5
Embeds 0
No embeds

No notes for slide

Transcript of "Spatial filtering using image processing"

  1. 1. SPATIAL FILTERING ANUJ ARORA B-TECH 2nd YEAR ELCTRICAL ENGG.
  2. 2. SPATIAL FILTERING (CONT’D)• Spatial filtering is defined by: (1) An operation that is performed on the pixels inside the Neighborhood (2)First we need to create a N*N matrix called a mask,kernel,filter(neighborhood). (3)The number inside the mask will help us control the kind of operation we are doing. (4)Different number allow us to blur,sharpen,find edges. output image
  3. 3. SPATIAL FILTERING NEIGHBORHOOD • Typically, the neighborhood is rectangular and its size is much smaller than that of f(x,y) - e.g., 3x3 or 5x5
  4. 4. SPATIAL FILTERING - OPERATION 1 1 1 1 ( , ) ( , ) ( , ) s t g x y w s t f x s y t Assume the origin of the mask is the center of the mask. / 2 / 2 / 2 / 2 ( , ) ( , ) ( , ) K K s K t K g x y w s t f x s y t for a K x K mask: for a 3 x 3 mask:
  5. 5. • A filtered image is generated as the center of the mask moves to every pixel in the input image. output image
  6. 6. STRANGE THINGS HAPPEN AT THE EDGES! Origin x y Image f (x, y) e e e e At the edges of an image we are missing pixels to form a neighbourhood e e e
  7. 7. HANDLING PIXELS CLOSE TO BOUNDARIES pad with zeroes or 0 0 0 ……………………….0 000……………………….0
  8. 8. LINEAR VS NON-LINEAR SPATIAL FILTERING METHODS • A filtering method is linear when the output is a weighted sum of the input pixels. • In this slide we only discuss about liner filtering. • Methods that do not satisfy the above property are called non-linear. • e.g.
  9. 9. LINEAR SPATIAL FILTERING METHODS • Two main linear spatial filtering methods: • Correlation • Convolution
  10. 10. CORRELATION • TO perform correlation ,we move w(x,y) in all possible locations so that at least one of its pixels overlaps a pixel in the in the original image f(x,y). / 2 / 2 / 2 / 2 ( , ) ( , ) ( , ) ( , ) ( , ) K K s K t K g x y w x y f x y w s t f x s y t
  11. 11. CONVOLUTION • Similar to correlation except that the mask is first flipped both horizontally and vertically. Note: if w(x,y) is symmetric, that is w(x,y)=w(-x,-y), then convolution is equivalent to correlation! / 2 / 2 / 2 / 2 ( , ) ( , ) ( , ) ( , ) ( , ) K K s K t K g x y w x y f x y w s t f x s y t
  12. 12. CORRELATION AND CONVOLUTION Correlation: Convolution:
  13. 13. HOW DO WE CHOOSE THE ELEMENTS OF A MASK? • Typically, by sampling certain functions. Gaussian 1st derivative of Gaussian 2nd derivative of Gaussian
  14. 14. FILTERS • Smoothing (i.e., low-pass filters) • Reduce noise and eliminate small details. • The elements of the mask must be positive. • Sum of mask elements is 1 (after normalization) Gaussian
  15. 15. FILTERS • Sharpening (i.e., high-pass filters) • Highlight fine detail or enhance detail that has been blurred. • The elements of the mask contain both positive and negative weights. • Sum of the mask weights is 0 (after normalization) 1st derivative of Gaussian 2nd derivative of Gaussian
  16. 16. SMOOTHING FILTERS: AVERAGING (LOW-PASS FILTERING)
  17. 17. SMOOTHING FILTERS: AVERAGING • Mask size determines the degree of smoothing and loss of detail. 3x3 5x5 7x7 15x15 25x25 original
  18. 18. SMOOTHING FILTERS: AVERAGING (CONT’D) 15 x 15 averaging image thresholding Example: extract, largest, brightest objects
  19. 19. SMOOTHING FILTERS: GAUSSIAN • The weights are samples of the Gaussian function mask size is a function of σ : σ = 1.4
  20. 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
  21. 21. SMOOTHING FILTERS: GAUSSIAN (CONT’D)
  22. 22. AVERAGING VS GAUSSIAN SMOOTHING Averaging Gaussian
  23. 23. SHARPENING FILTERS (HIGH PASS FILTERING) • Useful for emphasizing transitions in image intensity (e.g., edges).
  24. 24. SHARPENING FILTERS (CONT’D) • Note that the response of high-pass filtering might be negative. • Values must be re-mapped to [0, 255] sharpened imagesoriginal image
  25. 25. SHARPENING FILTERS: UNSHARP MASKING • Obtain a sharp image by subtracting a lowpass filtered (i.e., smoothed) image from the original image: - =
  26. 26. SHARPENING FILTERS: HIGH BOOST • Image sharpening emphasizes edges . • High boost filter: amplify input image, then subtract a lowpass image. • A is the number of image we taken for boosting. (A-1) + =
  27. 27. SHARPENING FILTERS: UNSHARP MASKING (CONT’D) • If A=1, we get a high pass filter • If A>1, part of the original image is added back to the high pass filtered image.
  28. 28. SHARPENING FILTERS: DERIVATIVES • Taking the derivative of an image results in sharpening the image. • The derivative of an image can be computed using the gradient.
  29. 29. SHARPENING FILTERS: DERIVATIVES (CONT’D) • The gradient is a vector which has magnitude and direction: | | | | f f x y or (approximation)
  30. 30. SHARPENING FILTERS: DERIVATIVES (CONT’D) • Magnitude: provides information about edge strength. • Direction: perpendicular to the direction of the edge.
  31. 31. SHARPENING FILTERS: GRADIENT COMPUTATION • Approximate gradient using finite differences: sensitive to horizontal edges sensitive to vertical edges Δx
  32. 32. SHARPENING FILTERS: GRADIENT COMPUTATION (CONT’D) • We can implement and using masks: • Example: approximate gradient at z5
  33. 33. SHARPENING FILTERS: GRADIENT COMPUTATION (CONT’D) • A different approximation of the gradient: •We can implement and using the following masks:
  34. 34. SHARPENING FILTERS: GRADIENT COMPUTATION (CONT’D) • Example: approximate gradient at z5
  35. 35. EXAMPLE f y f x
  36. 36. SHARPENING FILTERS: LAPLACIAN The Laplacian (2nd derivative) is defined as: (dot product) Approximate derivatives:
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×