[go: up one dir, main page]

0% found this document useful (0 votes)
12 views26 pages

DIP Lecture 7

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

DIP Lecture 7

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

Digital image processing (DIP)

Md. Zasim Uddin, PhD


Associate professor, Dept. Computer Science & Engineering
Begum Rokeya University, Rangpur
Content of previous lecture
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 |
The second-order isotropic derivative operator is the
Laplacian for a function (image) f(x,y)
 2
f  2
f
 f  2  2
2

2 f x y
 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 ) 2
Image Restoration and Reconstruction
 What is image restoration?
 Noise and images
 Noise models
 Noise removal using spatial domain filtering
What is image restoration?
 Image restoration attempts to restore images that have been
degraded
 Identify the degradation process and attempt to reverse it
 Similar to image enhancement, but more objective
Noise and images
 The sources of noise in digital images arise during image
acquisition (digitization) and transmission
 Imaging sensors can be affected by ambient conditions
 Interference can be added
to an image during transmission
Noise model
 We can consider a noisy image to be modelled as follows:

g ( x, y)  f ( x, y)   ( x, y)

 where f(x, y) is the original image pixel,


 η(x, y) is the noise term and g(x, y) is the resulting noisy pixel
 If we can estimate the noise model we can figure out how to restore
the image
Noise Models (cont...)
 There are many different Gaussian Rayleigh
models for the image
noise term η(x, y):

 Gaussian Erlang Exponential


• Most common model
 Rayleigh
 Erlang (Gamma)
Uniform
 Exponential Impulse
 Uniform
 Impulse
• Salt and pepper noise
Noise example

Histogram to go here

Original image
Noise example (cont…)

Histogram to go here

Original image
Filtering to remove noise
 We can use spatial filters of different kinds to
remove different kinds of noise
 The arithmetic mean filter is a very simple one
and is calculated as follows:
ˆf ( x, y )  1
 g ( s, t )
mn ( s ,t )S xy
1/ 1/ 1/
9 9 9
1/ 1/ 1/ This is implemented as the
9 9 9
simple filter
1/ 1/ 1/
9 9 9
Other means
 There are different kinds of mean filters all of which exhibit
slightly different behaviour:
 Geometric Mean
• similar smoothing to the arithmetic mean, but tends to lose less image
detail. 1
  mn
fˆ ( x, y )    g ( s, t )
( s ,t )S xy 
 Harmonic Mean
• Works well for salt noise, but fails for pepper noise.

mn
fˆ ( x, y ) 
1

( s ,t )S xy g ( s, t )
Other means
 There are different kinds of mean filters all of which exhibit
slightly different behaviour:
 Geometric Mean
• similar smoothing to the arithmetic mean, but tends to lose less image
detail. 1
  mn
fˆ ( x, y )    g ( s, t )
( s ,t )S xy 
 Harmonic Mean
• Works well for salt noise, but fails for pepper noise.

mn
fˆ ( x, y ) 
1

( s ,t )S xy g ( s, t )
Other means
 Contraharmonic Mean:

 g ( s, t )
( s ,t )S xy
Q 1

fˆ ( x, y ) 
 g ( s, t )
( s ,t )S xy
Q

Q is the order of the filter.


Positive values of Q eliminate pepper noise.
Negative values of Q eliminate salt noise.
It cannot eliminate both simultaneously.
Noise removal examples

Image
Original image corrupted
by Gaussian
noise

3x3
Geometric
3x3 mean filter (less
Arithmetic blurring than
mean filter AMF, the image
is sharper)
Noise removal examples (cont…)

Image corrupted by
pepper noise at 0.1

Filtering with a 3x3


Contraharmonic filter with
Q=1.5
Noise removal examples (cont…)

Image corrupted by salt


noise at 0.1

Filtering with a 3x3


Contraharmonic Filter with
Q=-1.5
Order statistics filters
 Spatial filters based on ordering the pixel
values that make up the neighbourhood
defined by the filter support.

 Useful spatial filters include


 Median filter
 Max and min filter
 Midpoint filter
 Alpha trimmed mean filter
Median filter
 Median Filter:

fˆ ( x, y )  median{g ( s, t )}
( s ,t )S xy

 Excellent at noise removal, without the smoothing effects that can


occur with other smoothing filters.

 Particularly good when salt and pepper noise is present.


Max and Min milter
 Max Filter:

fˆ ( x, y )  max {g ( s, t )}
( s ,t )S xy

 Min Filter:

fˆ ( x, y )  min {g ( s, t )}
( s ,t )S xy

Max filter is good for pepper noise and Min filter is good for salt noise.
Noise removal examples
Image Result of 1
corrupted pass with a
by Salt And 3x3 Median
Pepper noise Filter
at 0.2

Result of 2 Result of 3
passes with passes with
a 3x3 Median a 3*3 Median
Filter Filter

Repeated passes remove the noise better but also blur the image
Noise removal examples (cont…)

Image Image
corrupted corrupted
by Pepper by Salt
noise noise

Filtering Filtering
above above
with a 3x3 with a 3x3
Max Filter Min Filter
Adaptive filters
 The filters discussed so far are applied to an entire image
without any regard for how image characteristics vary from
one point to another.

 The behaviour of adaptive filters changes depending on


the characteristics of the image inside the filter region.
Adaptive median filtering
 The median filter performs relatively well on impulse noise
as long as the spatial density of the impulse noise is not
large.

 The adaptive median filter can handle much more spatially


dense impulse noise, and also performs some smoothing
for non-impulse noise.
Adaptive median filtering
In the adaptive median filter, the filter size changes
depending on the characteristics of the image.

Notation:
 Sxy = the support of the filter centerd at (x, y)
 zmin = minimum grey level in Sxy
 zmax = maximum grey level in Sxy
 zmed = median of grey levels in Sxy
 zxy = grey level at coordinates (x, y)
 Smax =maximum allowed size of Sxy
Adaptive median filtering (cont…)
Stage A: A1 = zmed – zmin
A2 = zmed – zmax
If A1 > 0 and A2 < 0, Go to stage B
Else increase the window size
If window size ≤ Smax repeat stage A
Else output zmed

Stage B: B1 = zxy – zmin


B2 = zxy – zmax
If B1 > 0 and B2 < 0, output zxy
Else output zmed
Adaptive median filtering (cont…)

Image corrupted by salt Result of filtering with a Result of adaptive


and pepper noise with 7x7 median filter median filtering with
probabilities Pa = Pb=0.25 Smax = 7

AMF preserves sharpness and details, e.g. the connector fingers.

You might also like