Вы находитесь на странице: 1из 26

DTEL (Department for Technology Enhanced Learning)

The Centre for Technology enabled Teaching & Learning , N Y S S, India

Teaching Innovation - Entrepreneurial - Global


DEPARTMENT OF ELECTRONICS &
TELECOMMUNICATION
VII-SEMESTER
PRINCIPLES OF IMAGE PROCESSING
Unit NO.2
Image Enhancement
It makes all the difference weather one sees darkness
through the light or brightness through shadows
David Lindsay

Dr. Y. K. Dubey
Assist. Professor
Department of Electronics & Telecommunication
Engineering, YCCE, Nagpur.
UNIT 2:- SYLLABUS

1 Spatial filtering: Image smoothing and sharpening

2 Two dimensional Fourier transform

3 Enhancement in frequency domain


LECTURE 1:- Spatial Filtering

• Spatial filter consists of


• (1) neighborhood, (typically a small rectangle), and
• (2) a predefined operation that is performed on image pixels
encompassed by the neighborhood.
• Filtering creates a new pixel with coordinates equal to
the center of the neighborhood and whose value is the
results of the filtering operation.
• If the operation performed on the image is linear then
the filter is called linear spatial filter otherwise the
filter is nonlinear.
• The neighborhood (subimage) is called a filter, mask,
kernel, template, or window,
• The values in a filter subimage are referred to as
coefficients, rather than pixels.
LECTURE 1:- Spatial Filtering
Fig shows the
mechanics of linear
spatial filtering using a
3X3 neighborhood. At
any point (x,y) in the
image the response,
g(x,y) of the the
processed image is the
sum of product of the
filter coefficient and
the image pixels
encompassed by the
filter
LECTURE 1:- Spatial Filtering

g ( x, y ) = w(−1, −1) f ( x − 1, y − 1) + w(−1, 0) f ( x − 1, y ) + .......


+ w(0, 0) f ( x, y ) + ........w(1,1) f ( x + 1, y + 1)

a b
g ( x, y ) =   w(s, t ) f ( x + s, y + t )
s =− a t =− b

(m − 1) b=
(n − 1)
a=
2 2
LECTURE 1:- Smoothing Spatial Filtering
❑ Smoothing Linear Filter (Image Averaging Operation)
❑ The output (response) of a smoothing, linear spatial filter is simply the
average of the pixels.
❑ These filters are called averaging filters. and also are referred to a lowpass
filters
❑ Replaces the intensity value of the pixel under consideration with the
average of the intensity values of its neighbourhood.
❑ The mask used here is

1 2 1
1 1 1 1
1 
 1 1 1 16 2 4 2
9
1 1 1 1 2 1

❑ O/p Image is a smooth image i.e. sharp edges are blurred.


❑ Blur will be more if mask size is getting bigger and bigger.
LECTURE 1:- Smoothing Spatial Filtering

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

for x=0, 1, 2, …., M-1 and y=0, 1, 2, ….. , N-1. The


LECTURE 1:- Smoothing Spatial Filtering

❑ Examples of Linear Smoothing


❑ Image Averaging Operation

Original Image Using 3×3 mask

Using 5×5 mask Using 9×9 mask


LECTURE 2:- Smoothing Spatial Filtering

• Order-statistics (Nonlinear) filters


• Response is based on ordering (ranking) the pixels
contained in the image area encompassed by the filter and
then replacing the value of the center pixel with the value
determined by the ranking results
• Best-known example in this category is the median filter,
which, replaces the value of a pixel by the median of the
gray levels in the neighborhood of that pixel.
• Median filters are quite popular for certain types of
random noise, they provide excellent noise reduction with
less blurring than linear filters.
• Median filters are effective in the presence of impulse noise
also called as salt and pepper noise.
LECTURE 2:- Smoothing Spatial Filtering
The median represents the 50th percentile of a ranked set of numbers

[ Before 100 85 98
Filtering ] 99 95 102 Sorting of neighboring pixels in Ascending Order
90 101 108
85 90 95 98 99 100 101 102 108

Median
[ After 100 85 98
99
Filtering ] 99 99 102
90 101 108

Other possibilities are using


The 100th percentile results in the so-called max filter, which is useful in
finding the brightest points in an image.
The 0th percentile filter is the min filter, which is useful in finding the darkest
points in an image.
LECTURE 2:- Smoothing Spatial Filtering
LECTURE 3:- Sharpening Spatial Filtering
• Foundation
• Increases the sharpness of the image
• Objective is to highlight the intensity details of an image
• Derivative operators generally increase the sharpness of the
image
• First order and second order derivative operators are used for
this purpose

First Order Derivative Filter Second Order Derivative Filter


❑ Must be zero in areas of ❑ Zero in flat areas
constant gray level ❑ Non-zero at the onset and
❑ Non-zero at the onset of a end of a gray level step or
gray-level step or ramp ramp
❑ Non-zero along ramp ❑ Zero along ramp of constant
slope
LECTURE 3:- Sharpening Spatial Filtering

df
= f ( x + 1) − f ( x) First Order Derivative
dx
d2 f
2
= f ( x + 1) + f ( x − 1) − 2 f ( x) Second Order Derivative
dx
8
7
6
5
4
3
2
1
0

5 5 4 3 2 1 0 0 0 6 0 0 0 0 1 3 1 0 0 0 0 7 7

f’

f’’

[Observation of 1st order and 2nd order Derivative over a 1-D signal]
LECTURE 3:- Sharpening Spatial Filtering
• Use of Second order derivative for Image Sharpening –The
Laplacian
• Laplacian of a function in continuous domain

 2
f  2
f
 f =
2
+ 2
x 2
y
• Laplacian in discrete domain

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 2 f
 f = 2 + 2 = f ( x + 1, y ) + f ( x − 1, y ) + f ( x, y + 1) + f ( x, y − 1) − 4 f ( x, y )
2

x y
LECTURE 4:- Sharpening Spatial Filtering

0 1 0 0 -1 0 1 1 1 -1 -1 -1

1 -4 1 -1 4 -1 1 -8 1 -1 8 -1

0 1 0 0 -1 0 1 1 1 -1 -1 -1

For Horizontal & vertical Lines For Horizontal & vertical and
diagonal Lines

Thus, the basic way in which the Laplacian for image enhancement
is use is as follows:

 f ( x, y ) −  f ( x, y )
2 If the center coefficient of the

g ( x, y ) = 
Laplacian mask is negative

 f ( x , y ) +  2
f ( x, y ) If the center coefficient of the
Laplacian mask is positive
LECTURE 4:- Sharpening Spatial Filtering
LECTURE 4:- Sharpening Spatial Filtering
LECTURE 5:- Sharpening Spatial Filtering

• Unsharp Masking and Highboost filtering


• A process used for many years in the printing and publishing
industry to sharpen images consists of subtracting an
unsharp (smoothed) version version of an image from the
original image.
• This process, called unsharp masking, consists of the
following steps
1. Blur the original image
2. Subtract the blurred image from the original (the resulting
difference is called mask)
3. Add the mask to the original
g mask ( x, y ) = f ( x, y ) − f ( x, y )
g ( x, y ) = f ( x, y ) + k * g mask ( x, y )
k=1, unsharp masking. k>1, the process is referred as high boost filtering
LECTURE 6:- Sharpening Spatial Filtering

• Use of First Derivatives for Enhancement—The


Gradient
• For a function f(x, y), the gradient of f at coordinates (x, y)
is defined as the two-dimensional column vector

 f 
f = mag ( f )
Gx   x  1
f =   =   = Gx 2 + G y 2  2
G y   f 
 y  1
 f  2  f  2
 2

=   +   
 x   y  
f Gx + G y
LECTURE 6:- Sharpening Spatial Filtering
Z2 Z2 Z3
Z4 Z5 Z6
Z7 Z8 Z9

Gx = ( Z8 − Z 5 ) and G y = ( Z 6 − Z 5 )
Gx = ( Z 9 − Z 5 ) and G y = ( Z8 − Z 6 )
1
f = ( Z 9 − Z 5 ) + ( Z 8 − Z 6 )
 2
2 2
  -1 0 0 -1

f  Z 9 − Z 5 + Z 8 − Z 6 0 1 1 0

Robert Cross Gradient operators


LECTURE 6:- Sharpening Spatial Filtering

-1 -2 -1 -1 0 1
0 0 0 -2 0 2
1 2 1 -1 0 1

f  ( Z 7 + 2Z8 + Z 9 ) − ( Z1 + 2Z 2 + Z 3 ) +
( Z3 + 2Z 6 + Z9 ) − ( Z1 + 2Z 4 + Z 7 )
Sobel Operator

DTEL
LECTURE 6:- Sharpening Spatial Filtering

-1 -1 -1 -1 0 1
0 0 0 -1 0 1
1 1 1 -1 0 1

f  ( Z 7 + Z8 + Z 9 ) − ( Z1 + Z 2 + Z 3 ) +
( Z3 + Z 6 + Z9 ) − ( Z1 + Z 4 + Z 7 )
Prewit Operator
LECTURE 6:- Sharpening Spatial Filtering
UNIT 2:-

References
• Digital Image Processing, R. C. Gonzalez and
R. E. Woods.
• Fundamentals of Digital Image Processing,
A. K. Jain.
UNIT 2:-

Thanks for your kind attention !!!

Вам также может понравиться