Sunteți pe pagina 1din 43

Digital Image

Processing

Dr. K. Adalarasu
KA Digital Image Processing Unit III OCT, 2012, PSNACET

Textbook and Materials


Rafael C. Gonzalez, Richard E.
Woods, Digital Image Processing,
2nd Edition, Pearson Education, 2003
Power Point Presentation

KA Digital Image Processing Unit III OCT, 2012, PSNACET

Reference
William K. Pratt, Digital Image Processing ,
John Willey ,2001
Milkman Sonka, Vaclav Hlavac, Roger Boyle,
Broos/Colic, Thompson Learniy, Vision,
Image Processing Analysis and Machine,
1999.
Jain A.K., Fundamentals of Digital Image
Processing, PHI, 1995.
Chanda Dutta Magundar, Digital Image
Processing and Applications, PHI, 2000
KA Digital Image Processing Unit III OCT, 2012, PSNACET

Image Enhancement
Techniques
Basics of Spatial
Filtering
KA Digital Image Processing Unit III OCT, 2012, PSNACET

Contents
Spatial filtering techniques
What is spatial filtering?
Smoothing Spatial filters
Sharpening Spatial Filters
Combining Spatial Enhancement Methods

KA Digital Image Processing Unit III OCT, 2012, PSNACET

Neighbourhood Operations
Neighbourhood operations simply
operate on a larger neighbourhood of
pixels than point operations
Neighbourhoods are mostly a
rectangle around a central pixel
Any size rectangle and any shape filter
are possible

KA Digital Image Processing Unit III OCT, 2012, PSNACET

Neighbourhood Operations
Origin

(x, y)

Neighbourhood

Image f (x, y)

KA Digital Image Processing Unit III OCT, 2012, PSNACET

Neighbourhood Operations
Each pixel in origin image, outcome is written
on same location at target image
Origin
Origin

Neighbourhood

Target

(x, y)

Image f (x, y)
KA Digital Image Processing Unit III OCT, 2012, PSNACET

Simple Neighbourhood Operations


Simple neighbourhood operations
example
Min
Set the pixel value to the minimum in the
neighbourhood

Max
Set the pixel value to the maximum in the
neighbourhood

KA Digital Image Processing Unit III OCT, 2012, PSNACET

Spatial Filtering
Use mask/ kernel/ template or window for
filtering
Values in a filter subimage are referred to as
coefficients, rather than pixel
Our focus will be on masks of odd sizes, e.g.
3x3, 5x5, 7x7,

KA Digital Image Processing Unit III OCT, 2012, PSNACET

10

11

Spatial Filtering Process


Origin

Simple 3*3
Neighbourhood

3*3 Filter

Original Image
Pixels

Image f (x, y)

KA Digital Image Processing Unit III OCT, 2012, PSNACET

Filter (w)

12

Spatial Filtering Process


eprocessed = n*e +
j*a + k*b + l*c +
m*d + o*f +
p*g + q*h + r*i

Above is repeated for every pixel in original


image to generate the filtered image

KA Digital Image Processing Unit III OCT, 2012, PSNACET

Spatial Filtering Process


Simply move filter mask from point to point in an
image
At each point (x, y), response of filter at that point is
calculated using a predefined relationship

R w1 z1 w2 z 2 ... wmn z mn
mn

wi zi
i i

W - mask coefficients
z- values of image gray levels corresponding to those
coefficients
mn is total number of coefficients in mask
KA Digital Image Processing Unit III OCT, 2012, PSNACET

13

14

Spatial Filtering: Equation Form


Filtering can be given in equation form as
shown above
Notations are based on the image shown to the
left
Mask of size m*n, we assume that m=2a+1 and
n=2b+1
Where a and b are nonnegative integers

KA Digital Image Processing Unit III OCT, 2012, PSNACET

Spatial Filtering: Equation Form

KA Digital Image Processing Unit III OCT, 2012, PSNACET

15

16

Spatial Filtering: Equation Form


Linear filtering of an image f of size M*N with
a filter mask of size m*n is given by
expression

KA Digital Image Processing Unit III OCT, 2012, PSNACET

Spatial Filtering
Process of linear filtering is similar to a
frequency domain convolution
Hence, linear spatial filtering is referred
as convolving a mask with an image
Filter masks are called as convolution
masks / convolution kernel

KA Digital Image Processing Unit III OCT, 2012, PSNACET

17

18

Spatial Filtering
Another representation of a general 3*3 spatial
filter mask

KA Digital Image Processing Unit III OCT, 2012, PSNACET

Smoothing Spatial Filters


Used for blurring and for noise reduction
Blurring is used in pre-processing steps
Such as removal of small details from an
image prior to (large) object extraction
Bridging of small gaps in lines or curves

Noise reduction
Blurring with a linear filter and also by
nonlinear filtering
KA Digital Image Processing Unit III OCT, 2012, PSNACET

19

Smoothing Linear Filters


Linear spatial filter is simply average
of pixels contained in neighborhood of
filter mask
Filters sometimes are called
averaging filters
They also are referred to a low-pass
filters

KA Digital Image Processing Unit III OCT, 2012, PSNACET

20

Smoothing Linear Filters

21

Simply average all of pixels in a


neighbourhood around a central value
Especially useful in removing noise from
images

Also useful for highlighting gross


detail
Most obvious application of
smoothing is noise reduction
KA Digital Image Processing Unit III OCT, 2012, PSNACET

Smoothing Linear Filters

22

Replacing value of every pixel in an image by


average of gray levels in neighborhood will
reduce the sharp transitions in gray levels
Sharp transitions
Random noise in image
Edges of objects in image

Thus, smoothing can reduce noises


(desirable) and blur edges (undesirable)

KA Digital Image Processing Unit III OCT, 2012, PSNACET

3x3 Smoothing Linear Filters


Weighted average, center is most important
Other pixels are inversely weighted as a
function of their distance from center of mask

box filter

weighted average

KA Digital Image Processing Unit III OCT, 2012, PSNACET

23

Smoothing Linear Filters


Major use of averaging filters is in reduction
of irrelevant detail in an image
Irrelevant
Pixel regions that are small with respect to size
of filter mask

KA Digital Image Processing Unit III OCT, 2012, PSNACET

24

25

Smoothing Spatial Filters


Origin

104 100 108


99 106 98
95

Simple 3*3
Neighbourhood

1
1
1
/9 100
/9 108
/9
104
1
/9 106
/9 198
/9
99

/9 190
/9 185
/9
95

90

85

Original Image
3*3 Smoothing
Pixels

/9

/9

/9

/9

/9

/9

/9

/9

/9

Filter

Filter

Image f (x, y)

e = 1/9*106 +
1
/9*104 + 1/9*100 + 1/9*108 +
1
/9*99 + 1/9*98 +
1
/9*95 + 1/9*90 + 1/9*85
= 98.3333

Above is repeated for every pixel in original


image to generate smoothed image
KA Digital Image Processing Unit III OCT, 2012, PSNACET

26

Spatial Filters
1 1 1
1

1
1
1

9
1 1 1
1 1 1
1 8 1

1 1 1

A low-pass filter

A high-pass filter

KA Digital Image Processing Unit III OCT, 2012, PSNACET

Smoothing Spatial Filters

27

An m*n mask would have a normalizing


constant equal to 1/mn
Spatial averaging filter in which all coefficients
are equal is sometimes called a box filter
Mask yields a so-called weighted average
Pixels are multiplied by different coefficients
Pixel at center of mask is multiplied by a higher value
than any other
Pixel more importance in calculation of the average

KA Digital Image Processing Unit III OCT, 2012, PSNACET

Weighted Smoothing Filters


Diagonal terms are further away from the
center than the orthogonal neighbors (by a
factor of 2)
General implementation for filtering an M*N
image with a weighted averaging filter of size
m*n (m and n odd) is given by the expression

KA Digital Image Processing Unit III OCT, 2012, PSNACET

28

Image Smoothing Example


Image at the top left is an
original image of size
500*500 pixels
Subsequent images
show the image after
filtering with an averaging
filter of increasing sizes
3, 5, 9, 15 and 35

Notice how detail begins


to disappear
KA Digital Image Processing Unit III OCT, 2012, PSNACET

29

30

Image Smoothing
Important application of spatial
averaging is to blur an image for
purpose getting a gross representation
of objects of interest
Intensity of smaller objects blends with
background and larger objects become
bloblike and easy to detect

KA Digital Image Processing Unit III OCT, 2012, PSNACET

31

Weighted Smoothing Filters

Image from the Hubble Space Telescope. (b) Image processed


by a 15*15 averaging mask (c) Result of thresholding (b)

KA Digital Image Processing Unit III OCT, 2012, PSNACET

32

Spatial Filtering

KA Digital Image Processing Unit III OCT, 2012, PSNACET

Order-Statistics Filters
Nonlinear filters whose response is based on
ordering (ranking) pixels contained in image
area encompassed by filter
Then replacing value of the center pixel with
value determined by the ranking result
One example is Median filter
Replaces value of a pixel by median of gray levels
in the neighborhood of that pixel

Median filters are quite popular because


Certain types of random noise, they provide
excellent noise-reduction capabilities
KA Digital Image Processing Unit III OCT, 2012, PSNACET

33

34

Median filter
Median filters are nonlinear
Median filtering reduces noise without
blurring edges and other sharp details

Median Filter

10 20 10
25 10 75

90 85 100

Sort: (10 10 10 20 25 75 85 90 100)

KA Digital Image Processing Unit III OCT, 2012, PSNACET

Order-Statistics Filters
With considerably less blurring than linear
smoothing filters of similar size
Particularly effective in presence of impulse
noise, also called salt-and-pepper noise
Because of its appearance as white and black dots
superimposed on an image Similarly

Max filter is used to find the brightest points in


an image and Min filter is used to find the
opposite

KA Digital Image Processing Unit III OCT, 2012, PSNACET

35

Averaging Filter Vs. Median Filter


Example

Original Image
With Noise

Image After
Averaging Filter

Image After
Median Filter

Filtering is often used to remove noise from


images
Sometimes a median filter works better than
an averaging filter
KA Digital Image Processing Unit III OCT, 2012, PSNACET

36

Averaging Filter Vs. Median Filter


Example
Original

KA Digital Image Processing Unit III OCT, 2012, PSNACET

37

Averaging Filter Vs. Median Filter


Example
Averaging
Filter

KA Digital Image Processing Unit III OCT, 2012, PSNACET

38

Averaging Filter Vs. Median Filter


Example

Median
Filter

KA Digital Image Processing Unit III OCT, 2012, PSNACET

39

40

Spatial Filtering
Salt&Pepper
noise added

Original

3x3
averaging
filter

3x3
median
filter

KA Digital Image Processing Unit III OCT, 2012, PSNACET

41

Blurring vs. Sharpening


Blurring can be done in spatial domain
by pixel averaging in a neighbors
Averaging is analogous to integration
Thus, we can guess that sharpening
must be accomplished by spatial
differentiation

KA Digital Image Processing Unit III OCT, 2012, PSNACET

42

Summary
The image enhancement spatial
smoothing technique is studied.
The types of smoothing filtering, such as
averaging filter, weighted averaging and
median filters are learned.

KA Digital Image Processing Unit III OCT, 2012, PSNACET

43

Questions
1. What is the another name for
averaging filter?
2. Name some order statistics
filters

KA Digital Image Processing Unit III OCT, 2012, PSNACET

S-ar putea să vă placă și