Spatial Filtering : 1
Spatial FilteringSpatial Filtering
Spatial Filtering : 2
Basics of Spatial FilteringBasics of Spatial Filtering
Image enhancement operations can also work with the values of the image pixels in the neighborhood and the corresponding values of a subimage that has the same dimensions as the neighborhood.
The subimage is called a filter, mask, kernel, template, or window.
The values in a filter subimage are referred to as coefficients, rather than pixels.
The process consists simply of moving the filter mask from point to point in an image.
For linear spatial filtering, the response is given by a sum of products of the filter coefficients and the corresponding image pixels in the area spanned by the filter mask
Spatial Filtering : 3
Linear Spatial FilterLinear Spatial Filter
Spatial Filtering : 4
Linear Spatial Filter (Cont.)Linear Spatial Filter (Cont.)
The result (or response), R, of linear filtering with the filter mask at a point (x, y) in the image is:
In general, linear filtering of an image f of size M X N with a filter mask of size m X n is given by the expression:
( 1, 1) ( 1, 1) ( 1,0) ( 1, )
(0,0) ( , ) (1,0) ( 1, ) (1,1) ( 1, 1)
R w f x y w f x y
w f x y w f x y w f x y
( 1)/2 ( 1)/2
( 1)/2 ( 1)/2
( , ) ( , ) ( , )m n
s m t n
g x y w s t f x s y t
Spatial Filtering : 5
Linear Spatial Filter (Cont.)Linear Spatial Filter (Cont.)
When interest lies on the response, R, of an m X n mask at any point (x, y), and not on the mechanics of implementing mask convolution
1 1 2 2
1
mn mn
mn
i ii
R w z w z w z
w z
Spatial Filtering : 6
Linear Spatial Filter (Cont.)Linear Spatial Filter (Cont.)
1 1 2 2 9 9
9
1
i ii
R w z w z w z
w z
Spatial Filtering : 7
Noise reduction by Spatial FilteringNoise reduction by Spatial Filtering
Image averaging takes advantage of information redundancy from the individual images to reduce noise
Not always possible to acquire so many images!
Alternative option: Take advantage of information redundancy from different pixels within the same image to reduce noise
Spatial Filtering : 8
Averaging FilterAveraging Filter
Instead of averaging between images, we can average neighboring pixels
9
1
1
9 ii
R z
Spatial Filtering : 9
Averaging FilterAveraging Filter
Spatial Filtering : 10
Weighted Average FilterWeighted Average Filter
Problem: Simple averaging of neighboring pixels lead to over-smoothing
Possible solution: Instead of weighting all neighboring pixels equally, assign higher weights to pixels that are closer to the pixel being convolved
Spatial Filtering : 11
Weighted Average FilterWeighted Average Filter
Spatial Filtering : 12
Weighted Averaging Filter:Weighted Averaging Filter:ExampleExample
Spatial Filtering : 13
Weighted Averaging Filter:Weighted Averaging Filter:ExampleExample
Spatial Filtering : 14
Order-Statistic FiltersOrder-Statistic Filters
Nonlinear spatial filters
Steps
Order pixels within an area
Replace value of center pixel with value determined by ordering
Best known example: median filters
( ) ( ) ( )H af bg aH f bH g
Spatial Filtering : 15
Median FilterMedian Filter
Provides good noise reduction for certain types of noise such as impulse noise
Considerably less blurring than weighted averaging filter
Forces a pixel to be like its neighbors
Steps
Order pixels within an area
Replace value of center pixel with median value (half of all pixels have intensities greater than or equal to the median value)
Spatial Filtering : 16
Median Filter: ExampleMedian Filter: Example
Spatial Filtering : 17
Median Filter: ExampleMedian Filter: Example
Spatial Filtering : 18
Spatial Filtering: SharpeningSpatial Filtering: Sharpening
Goal: highlight or enhance details in images
Some applications:
Photo enhancement
Medical image visualization
Industrial defect detection
Spatial Filtering : 19
Sharpening Spatial FilteringSharpening Spatial Filtering
Goal: highlight or enhance details in images
Some applications:
Photo enhancement
Medical image visualization
Industrial defect detection
Basic principle:
Averaging (blurring) is analogous to integration
Therefore, logically, sharpening accomplished by differentiation
Spatial Filtering : 20
Derivatives of digital functionDerivatives of digital function
First-order derivative
Second-order derivative
( 1) ( )f
f x f xx
2
2( 1) ( 1) 2 ( )
ff x f x f x
x
Spatial Filtering : 21
Derivatives of digital functionDerivatives of digital function
First-order derivatives generally produce thicker edges
Second-order derivatives have stronger response to fine detail (e.g., thin lines and points)
First-order derivatives have stronger response to step changes
Second-order derivatives produce double response at step changes
Spatial Filtering : 22
Derivatives of digital function: ExampleDerivatives of digital function: Example
Spatial Filtering : 23
Derivatives of digital function: ExampleDerivatives of digital function: Example
Spatial Filtering : 24
Sharpening using LaplacianSharpening using Laplacian
Second-order derivatives is better suited for most applications for sharpening
How?
By constructing a filter based on discrete formulation of second-order derivatives
Simplest isotropic derivative operator: Laplacian
2 22
2 2
f ff
x y
Spatial Filtering : 25
How to create Laplacian filterHow to create Laplacian filter
2 22
2 2
f ff
x y
2
2( 1, ) ( 1, ) 2 ( , )
ff x y f x y f x y
x
2
2( , 1) ( , 1) 2 ( , )
ff x y f x y f x y
y
2 ( 1, ) ( 1, ) ( , 1) ( , 1) 4 ( , )f f x y f x y f x y f x y f x y
Spatial Filtering : 26
Laplacian FilterLaplacian Filter
Spatial Filtering : 27
Sharpening using LaplacianSharpening using Laplacian
Problem: While applying Laplacian highlights fine detail, it de-emphasizes smooth regions (e.g., background features)
Results in featureless background with grayish fine details
Solution: Add original image to recover background features
2
2
( , ) ( , ), negative filter center( , )
( , ) ( , ), positive filter center
f x y f x yg x y
f x y f x y
Spatial Filtering : 28
ExampleExample
Spatial Filtering : 29
Sharpening using Unsharp MaskingSharpening using Unsharp Masking
Subtract blurred version of image from the
image itself to produce sharp image
( , ) ( , ) ( , )g x y f x y f x y
Spatial Filtering : 30
ExampleExample
Spatial Filtering : 31
Sharpening using High-boost FilteringSharpening using High-boost Filtering
Generalization of unsharp masking
As A increases, contribution of sharpening decreases
( , ) ( , ) ( , )g x y Af x y f x y
Spatial Filtering : 32
Sharpening using High-boost FilteringSharpening using High-boost Filtering
Spatial Filtering : 33
Example
Spatial Filtering : 34
First Derivatives for EnhancementFirst Derivatives for Enhancement
Implemented as magnitude of gradient in image processing
f
xf
f
y
1/222f f
fx y
Spatial Filtering : 35
ImplementationImplementation
Problem: Expensive to implement directly
Solution: Approximate using absolute values
Can be implemented using two 2x2 filters
Even filters difficult to implement, so 3x3 filters are used for approximation
9 5 8 6f z z z z
7 8 9 1 2 3
3 6 9 1 4 7
( 2 ) ( 2 )
( 2 ) ( 2 )
f z z z z z z
z z z z z z
Spatial Filtering : 36
Gradient MasksGradient Masks
Spatial Filtering : 37
Example: Defect DetectionExample: Defect Detection
Top Related