0% found this document useful (0 votes)
29 views32 pages

Dip Spatial Filtering

The document discusses techniques for image enhancement through histogram equalization, spatial filtering, and sharpening filters. It begins with an explanation of histogram equalization, which modifies the intensity values of an image's pixels to enhance contrast. It then covers spatial filtering, including linear filtering operations like smoothing and sharpening. Smoothing filters are used to reduce noise, while sharpening filters like the Laplacian operator enhance edges. The document also discusses unsharp masking and highboost filtering for sharpening. It explains how these techniques subtract a blurred version of an image from the original to create a "mask" that is then added back to the image. Finally, it covers using image gradients and derivative-based filters like Roberts and S

Uploaded by

Madhuri Potluri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views32 pages

Dip Spatial Filtering

The document discusses techniques for image enhancement through histogram equalization, spatial filtering, and sharpening filters. It begins with an explanation of histogram equalization, which modifies the intensity values of an image's pixels to enhance contrast. It then covers spatial filtering, including linear filtering operations like smoothing and sharpening. Smoothing filters are used to reduce noise, while sharpening filters like the Laplacian operator enhance edges. The document also discusses unsharp masking and highboost filtering for sharpening. It explains how these techniques subtract a blurred version of an image from the original to create a "mask" that is then added back to the image. Finally, it covers using image gradients and derivative-based filters like Roberts and S

Uploaded by

Madhuri Potluri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 32

Histogram Equalization

Continuous case:
r
s  T (r )  ( L  1)  pr ( w)dw
0

Discrete values:
k
sk  T (rk )  ( L  1) pr ( rj )
j 0
k nj L 1 k
 ( L  1)   nj k=0,1,..., L-1
j  0 MN MN j 0

11/02/2023 1
Example: Histogram Equalization
Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096) has the
intensity distribution shown in following table.
Get the histogram equalization transformation function and give the p s(sk)
for each sk.

11/02/2023 2
Example: Histogram Equalization

0
s0  T (r0 )  7 pr (rj )  7  0.19  1.33 1
j 0
1
s1  T (r1 )  7 pr (rj )  7  (0.19  0.25)  3.08 3
j 0
s2  4.55  5 s3  5.67  6
s4  6.23  6 s5  6.65  7
s6  6.86  7 s7  7.00  7
11/02/2023 3
Example: Histogram Equalization

11/02/2023 4
11/02/2023 5
Spatial Filtering
A spatial filter consists of (a) a neighborhood, and (b) a
predefined operation

Linear spatial filtering of an image of size MxN with a filter


of size mxn is given by the expression

a b
g ( x, y )    w(s, t ) f ( x  s, y  t )
s  a t  b

02/11/2023 6
Spatial Filtering

02/11/2023 7
Spatial Correlation
The correlation of a filter w( x, y) of size m  n
with an image f ( x, y ), denoted as w( x, y) f ( x, y)

a b
w( x, y ) f ( x, y )    w(s, t ) f ( x  s, y  t )
s  a t  b

02/11/2023 8
Spatial Convolution
The convolution of a filter w( x, y) of size m  n
with an image f ( x, y ), denoted as w( x, y) f ( x, y)

a b
w( x, y ) f ( x, y )    w( s, t ) f ( x  s, y  t )
s  a t  b

02/11/2023 9
Smoothing Spatial Filters
Smoothing filters are used for blurring and for noise
reduction

Blurring is used in removal of small details and bridging of


small gaps in lines or curves

Smoothing spatial filters include linear filters and nonlinear


filters.

02/11/2023 10
Spatial Smoothing Linear Filters

The general implementation for filtering an M  N image


with a weighted averaging filter of size m  n is given
a b

  w(s, t ) f ( x  s, y  t )
g ( x, y )  s  a t  b
a b

  w( s, t )
s  a t  b

where m  2a  1, n  2b  1.

02/11/2023 11
Two Smoothing Averaging Filter Masks

02/11/2023 12
02/11/2023 13
Example: Gross Representation of Objects

02/11/2023 14
Order-statistic (Nonlinear) Filters

— Nonlinear

— Based on ordering (ranking) the pixels contained in the


filter mask

— Replacing the value of the center pixel with the value


determined by the ranking result

E.g., median filter, max filter, min filter

02/11/2023 15
Example: Use of Median Filtering for Noise Reduction

02/11/2023 16
Sharpening Spatial Filters

► Foundation

► Laplacian Operator

► Unsharp Masking and Highboost Filtering

► Using First-Order Derivatives for Nonlinear Image


Sharpening — The Gradient

02/11/2023 17
Sharpening Spatial Filters: Foundation

► The first-order derivative of a one-dimensional function f(x)


is the difference

f
 f ( x  1)  f ( x)
x

► The second-order derivative of f(x) as the difference

2 f
 f ( x  1)  f ( x  1)  2 f ( x)
x 2

02/11/2023 18
02/11/2023 19
Sharpening Spatial Filters: Laplace Operator

The second-order isotropic derivative operator is the


Laplacian for a function (image) f(x,y)

 2
f  2
f
 f  2  2
2

x y
2 f
 f ( x  1, y )  f ( x  1, y )  2 f ( x, y )
x 2

2 f
 f ( x, y  1)  f ( x, y  1)  2 f ( x, y )
y 2

 2 f  f ( x  1, y )  f ( x  1, y )  f ( x, y  1)  f ( x, y  1)
- 4 f ( x, y )

02/11/2023 20
Sharpening Spatial Filters: Laplace Operator

02/11/2023 21
Sharpening Spatial Filters: Laplace Operator

Image sharpening in the way of using the Laplacian:

g ( x, y )  f ( x, y )  c  2 f ( x, y ) 
where,
f ( x, y ) is input image,
g ( x, y ) is sharpenend images,
c  -1 if  2 f ( x, y ) corresponding to Fig. 3.37(a) or (b)
and c  1 if either of the other two filters is used.

02/11/2023 22
02/11/2023 23
Unsharp Masking and Highboost Filtering

► Unsharp masking
Sharpen images consists of subtracting an unsharp (smoothed)
version of an image from the original image
e.g., printing and publishing industry

► Steps
1. Blur the original image
2. Subtract the blurred image from the original
3. Add the mask to the original

02/11/2023 24
Unsharp Masking and Highboost Filtering

Let f ( x, y ) denote the blurred image, unsharp masking is


g mask ( x, y )  f ( x, y )  f ( x, y )
Then add a weighted portion of the mask back to the original
g ( x, y )  f ( x, y )  k * g mask ( x, y ) k 0

when k  1, the process is referred to as highboost filtering.

02/11/2023 25
Unsharp Masking: Demo

02/11/2023 26
Unsharp Masking and Highboost Filtering: Example

02/11/2023 27
Image Sharpening based on First-Order Derivatives

For function f ( x, y ), the gradient of f at coordinates ( x, y )


is defined as
 f 
 g x   x 
f  grad( f )      
 g y   f 
 y 

The magnitude of vector f , denoted as M ( x, y)


Gradient Image M ( x, y)  mag(f )  g x 2  g y 2

02/11/2023 28
Image Sharpening based on First-Order Derivatives

The magnitude of vector f , denoted as M ( x, y)


M ( x, y)  mag(f )  g x 2  g y 2

M ( x, y ) | g x |  | g y |

z1 z2 z3
M ( x, y ) | z8  z5 |  | z6  z5 |
z4 z5 z6
z7 z8 z9
11/02/2023 29
Image Sharpening based on First-Order Derivatives

Roberts Cross-gradient Operators


M ( x, y ) | z9  z5 |  | z8  z6 |

Sobel Operators
M ( x, y ) | ( z7  2 z8  z9 )  ( z1  2 z 2  z3 ) |
z1 z2 z3  | ( z3  2 z6  z9 )  ( z1  2 z 4  z7 ) |
z4 z5 z6
z7 z8 z9
11/02/2023 30
Image Sharpening based on First-Order Derivatives

11/02/2023 31
Example

11/02/2023 32

You might also like