06 spatial filtering DIP
description
Transcript of 06 spatial filtering DIP
![Page 1: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/1.jpg)
Spatial Filtering : 1
Spatial FilteringSpatial Filtering
![Page 2: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/2.jpg)
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
![Page 3: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/3.jpg)
Spatial Filtering : 3
Linear Spatial FilterLinear Spatial Filter
![Page 4: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/4.jpg)
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
![Page 5: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/5.jpg)
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
![Page 6: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/6.jpg)
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
![Page 7: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/7.jpg)
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
![Page 8: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/8.jpg)
Spatial Filtering : 8
Averaging FilterAveraging Filter
Instead of averaging between images, we can average neighboring pixels
9
1
1
9 ii
R z
![Page 9: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/9.jpg)
Spatial Filtering : 9
Averaging FilterAveraging Filter
![Page 10: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/10.jpg)
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
![Page 11: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/11.jpg)
Spatial Filtering : 11
Weighted Average FilterWeighted Average Filter
![Page 12: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/12.jpg)
Spatial Filtering : 12
Weighted Averaging Filter:Weighted Averaging Filter:ExampleExample
![Page 13: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/13.jpg)
Spatial Filtering : 13
Weighted Averaging Filter:Weighted Averaging Filter:ExampleExample
![Page 14: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/14.jpg)
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
![Page 15: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/15.jpg)
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)
![Page 16: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/16.jpg)
Spatial Filtering : 16
Median Filter: ExampleMedian Filter: Example
![Page 17: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/17.jpg)
Spatial Filtering : 17
Median Filter: ExampleMedian Filter: Example
![Page 18: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/18.jpg)
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
![Page 19: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/19.jpg)
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
![Page 20: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/20.jpg)
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
![Page 21: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/21.jpg)
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
![Page 22: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/22.jpg)
Spatial Filtering : 22
Derivatives of digital function: ExampleDerivatives of digital function: Example
![Page 23: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/23.jpg)
Spatial Filtering : 23
Derivatives of digital function: ExampleDerivatives of digital function: Example
![Page 24: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/24.jpg)
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
![Page 25: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/25.jpg)
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
![Page 26: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/26.jpg)
Spatial Filtering : 26
Laplacian FilterLaplacian Filter
![Page 27: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/27.jpg)
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
![Page 28: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/28.jpg)
Spatial Filtering : 28
ExampleExample
![Page 29: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/29.jpg)
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
![Page 30: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/30.jpg)
Spatial Filtering : 30
ExampleExample
![Page 31: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/31.jpg)
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
![Page 32: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/32.jpg)
Spatial Filtering : 32
Sharpening using High-boost FilteringSharpening using High-boost Filtering
![Page 33: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/33.jpg)
Spatial Filtering : 33
Example
![Page 34: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/34.jpg)
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
![Page 35: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/35.jpg)
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
![Page 36: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/36.jpg)
Spatial Filtering : 36
Gradient MasksGradient Masks
![Page 37: 06 spatial filtering DIP](https://reader033.fdocuments.in/reader033/viewer/2022052307/554f6219b4c905c8088b4aee/html5/thumbnails/37.jpg)
Spatial Filtering : 37
Example: Defect DetectionExample: Defect Detection