You are on page 1of 60

Image averaging

Noisy image can be enhanced by averaging it


over a set of images

A noisy image (g(x,y)) can be expressed as

g( x , y ) f ( x , y ) ( x , y )

where

f ( x, y)
( x, y)
If the noise

Original image

Noise

(x,y) is uncorrelated, then

The expected value of the noise


The expected covariance of the
two random variables = 0

(x,y) = 0

{ gi ( x , y )}

Represents a set of noisy image

The average image is formed by,

1
g( x , y )
K

g ( x, y)
i 1

fi

K i 1
K

i 1

Take expectation either side


K

1
E ( g ) E ( f i )
K i 1

E ( i )

i 1

f i is a constant and same for all the images

E{ f i } f i
&

E{i } 0
E{ g( x, y )} f ( x, y )

K=8

K=16

K=64

K=128

Scaling of the gray levels during mathematical


operation

unscaled

=
scaled

unscaled

scaled

Mask filtering in spatial domain

Subimage

Subimage filter, mask, kernel, template, or window

Subimage is a small matrix whose elements are


called COFFIECIENTS
Preferably, the size of the mask should be odd
If (m x n) size of the mask
Then, m=2a+1 and n=2b+1

a, b are integers

Linear filter:

g( x , y )

w( s, t ) f ( x s, y t )

sa t b

The coefficients w(x,y) are defined by the


user; depending on the nature of the filter
required

eg.,
for an average filter of mask 3x3, each coefficient
should be 1/9

W=

1/9

To perform the averaging, vary


x =0,1,2,.M-1
y =0,1,2N-1

W=

1/16

Weighted average

Hence the general expression for avg.

g( x , y )

w( s, t ) f ( x s, y t )

sa t b

w( s, t )

sa t b

Mask reaches the border:

(a)

(b)

Padding

Mask size
--, 3

5,9

15, 35

Averaging removes smaller details


It leads to blurring

Non-linear filters:
e.g., Median filter, variance filter

Median filter is very powerful in removing random noise


with considerably less blurring than linear avg. filter

of similar size

Median filters are effective for impulse noise.

Find median of the set of 15 numbers

5, 7, 4, 5, 3, 6, 8, 7, 12, 1, 0, 4, 14, 1, 3
a) Arrange them as
0, 1, 1, 3, 3, 4, 4, 5, 5, 6, 7, 7, 8, 12, 14
Median = 5

Find median of the set of 14 numbers


87, 55, 67, 87, 98, 80, 45, 65, 75, 67, 87, 92, 87, 63

Arrange them
45, 55, 63, 65, 67, 67, 75, 80, 87, 87, 87, 87, 92, 98

Median = Avg(75,80) = 77.5

Noisy image

Median filtered image


(3x3 mask)

Comparison

a) Max filter
The pixel value is replaced by the maximum calculated
from the neighborhood.

b) Min Filter
The pixel value is replaced by the minimum calculated
from the neighborhood.

c) Mid point filter


The pixel value is replaced by the 0.5*(min+max)
calculated from the neighborhood.

Highlight the finer details


Remove the blur

Averaging leads to blurring effect

Averaging analogous to INTEGRATION

Hence, deblurring or sharpening


DIFFERENTIATION
or DISCONTINUITY

Image differentiation enhances edges


and other discontinuities (like noise)

and deemphasizes area with slowly


varying gray levels

1st order derivative of 1-D function:

f
f ( x 1) f ( x ) ;
x

x is discrete

Position

Gray level

Properties::
a) Must be zero in the flat region
b) Must be non-zero at the onset of a gray level
step or ramp
c) Must be non-zero along the ramps.

y-derivative

x-derivative

For 2nd derivative, expand a function by

Taylor series:

f h f
f ( x h) f ( x ) h
....
2
x 2! x
2

Again,

f h f
f ( x h) f ( x ) h
....
2
x 2! x
2

Add the two, for a discrete image, h=1

f
f ( x 1) f ( x 1) 2 f ( x )
2
x
2

2nd order derivative of 1-D function

Properties::
a) Must be zero in the flat region

b) Must be non zero at the onset and at the


end of the gray level step or ramp
c) Must be zero along the ramps of constant
slope

Is 2nd order derivative isotropic???

First derivative can be used to detect the


presence of an edge (i.e. to determine if the
point is on a ramp)
The sign of second derivative can be used to
determine whether an edge point lies on the
dark or bright side of an edge

Second derivative produces two values at every edge


which is not desirable
Second derivative can be used to locate the center
of a very thick edge.

Effect of noise on
edge detection!!!!!

In conclusion
1st order derivatives generally produce thicker
edges in an image.
1st order derivatives have stronger response to
the gray level steps in the image.
2nd order derivatives have a stronger response
to fine details such as thin lines and isolated
points.
2nd order derivatives produce a double response
at the step changes in gray level.

The 2nd derivative is better than the 1st

because of its ability to enhance finer


details in the image.

Use of 2nd derivative for image enhancement

--- The Laplacian


2 f
f ( x 1, y ) f ( x 1, y ) 2 f ( x , y )
2
x

2 f
f ( x , y 1) f ( x , y 1) 2 f ( x , y )
2
y

2
2

f
2
f
2
2
x
y
f ( x 1, y ) f ( x 1, y ) f ( x , y 1) f ( x , y 1) 4 f ( x , y )

w( s , t ) f ( x s , y t )
0

-4

w =

The Laplacian derivative is used to highlight


gray level discontinuities and deemphasize
the region with slow varying gray levels.

Image that have grayish edge line and other


discontinuities , all superimposed on a dark
featureless background.

The image can be sharpen by adding or

subtracting the original image with the


Laplacian, i.e.,
g( x , y ) f ( x , y ) f ( x , y ) If the center coefficient of the
Laplacian mask is negative
or
2

g( x , y ) f ( x , y ) 2 f ( x , y ) If the center coefficient of the


Laplacian mask is positive

Simplification

g( x , y ) f ( x , y ) 2 f ( x , y )
f ( x , y ) f ( x 1, y ) f ( x 1, y ) .... 4 f ( x , y )
5 f ( x , y ) f ( x 1, y ) .....

-1

-1

-1

-1

w =

Composite mask

Unsharp masking and high-boost filtering


The process in which the blurred version
of the image is subtracted from the original

image is known as UNSHARP MASKING

f edge ( x, y ) f ( x, y ) f ( x, y )
fedge(x,y) = edge of the image f(x,y)
f(x,y) is the blurred version of f(x,y)

f s ( x , y ) f edge ( x , y ) f ( x , y )
f ( x, y) f ( x, y) f ( x, y)

The generalization of unsharp masking is


high-boost filtering

f hb ( x, y ) Af ( x, y ) f ( x, y )
where

A 2

f hb ( x, y ) ( A 1) f ( x, y ) f ( x, y ) f ( x, y )
f hb ( x, y ) ( A 1) f ( x, y ) f edge ( x, y )
Recall:

f edge ( x, y ) f ( x, y )

f hb ( x , y ) ( A 1) f ( x , y ) 2 f ( x , y )

Central coefficient is -

or
f hb ( x , y ) ( A 1) f ( x , y ) 2 f ( x , y ) Central coefficient is+

Composite mask

-1

-1

A+3

-1

-1

w =

A=1

A=2.0

A=2.7

You might also like