Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 55

Enhancement

Using
Arithmetic /
Logic Operators
2
When dealing with logic operations on
gray-level images, pixel values are
processed as strings of binary numbers

AND, OR, COMPLEMENT (NOT)

3
4
NOT
Operation
8 bit black 8 bit white
pixel pixel

NOT logic operation performs the same


function as Negative Transformation

AND & OR operations are used for


Masking.
(as they can be used for selecting sub
images in an image)

5
Obtained by computing the difference
between all pairs of corresponding pixels
from images f & h.
Subtraction enhances the differences
between the two images

6
Mask Mode Radiography
One of the most successful commercial
applications of image subtraction

Example: imaging blood vessels and arteries in a


body. Blood stream is injected with a dye and
X-ray images are taken before and after the
injection

– f(x, y): image after injecting a dye


– h(x, y): image before injecting the dye (the mask)

• The difference of the 2 images yields a clear


display of the blood flow paths.
7
(a) Mask image
(b) Image (after injection of dye into the
bloodstream) with mask subtracted out
8
• A noisy image:
g ( x, y )  f ( x, y )  n ( x, y )
• Averaging M different noisy images:
M
1
g ( x, y ) 
M
 g ( x, y )
i 1
i

• As M increases, the variability of the pixel


values at each location decreases.

• This means that g(x, y) approaches f(x, y) as


the number of noisy images used in the 9
An important application of image averaging
is in the field of astronomy

10
Enhancement techniques
based on the
pixels of an image are
often referred to as
Spatial filtering

Spatial filtering is the filtering


operations that are performed directly on
the pixels of an image

12
Background
• Filter term in “Digital image
processing” is referred to the
subimage
• There are others term to call
subimage such as mask, kernel,
template, or window
• The value in a filter subimage are
referred as coefficients, rather than
pixels.

13
Mechanics of spatial
filtering
• The process consists simply of moving
the filter mask from point to point in
an image.
• At each point (x, y) the response of
the filter at that point is calculated
using a predefined relationship

14
Linear spatial filtering
The result is the sum of products of the mask
coefficients with the corresponding pixels
directly under the mask.

For a 3 x 3 mask, the result (or response), R, of


linear filtering with the filter mask at point (x, y)
in the image is

15
16
Note: Linear filtering

• The coefficient w(0,0) coincides with


image value f(x, y), indicating that the
mask is centered at (x, y) when the
computation of sum of products takes
place.
• For a mask of size m x n, we assume that
m=2a+1 and n=2b+1, where a and b are
nonnegative integer. Then m and n are
odd.

17
In general, linear filtering of an image f
of size M x N with a filter mask of size
m x n is given by the expression:
a b
g ( x, y )    w(s, t ) f ( x  s, y  t )
s   at   b

where (as per the previous discussion)


a = (m – 1) / 2 & b = (n – 1) / 2

To generate a complete filtered image, the above


equation must be applied for
x = 0, 1, …, M-1 & y = 0, 1, …, N-1
Slide 47 18
The process of linear filtering similar to a
frequency domain concept called
“convolution”
mn
R  w1 z1  w2 z 2  ...  wmn z mn   wi zi
i 1
w1 w2 w3 9

w4 w5 w6 R  w1 z1  w2 z 2  ...  w9 z9   wi zi
i 1
w7 w8 w9
Where the w’s are mask coefficients, the
z’s are the value of the image gray levels
corresponding to those coefficients
19
Nonlinear spatial filtering
Nonlinear spatial filters also operate
on neighborhoods, and the mechanics
of sliding a mask past an image are
the same as was just outlined.
The filtering operation is based
conditionally on the values of the
pixels in the neighborhood under
consideration.

20
Smoothing Spatial Filters
Smoothing filters are used for blurring
and for noise reduction.

 Blurring is used in preprocessing steps,


such as removal of small details from
an image prior to object extraction,
and bridging of small gaps in lines or
curves

 Noise reduction can be accomplished by


blurring with a linear or non linear
filter. 21
Types of Smoothing filters

There are 2 types of


smoothing spatial filters

Smoothing Linear Filters

Order-Statistics Filters

22
Smoothing Linear Filters
Averaging Filters / Lowpass Filters
Linear spatial filter is simply the
average of the pixels contained in the
neighborhood of the filter mask.
Sometimes called “averaging filters”.
The idea is replacing the value of
every pixel in an image by the
average of the gray levels in the
neighborhood defined by the filter
mask. 23
Two 3x3
Smoothing Linear Filters

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

Standard average Weighted average

24
5x5 Smoothing Linear Filters

1 1 1 1 1

1 1 1 1 1
1
 1 1 1 1 1
25
?
1 1 1 1 1

1 1 1 1 1
25
Smoothing Linear Filters
The general implementation for filtering
an M x N image with a weighted
averaging filter of size m x n is given by
the expression
a b

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

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

26
Result of
Smoothing Linear Filters
Original Image

[3x3] [5x5] [7x7]

27
Order-Statistics Filters
Order-statistics filters are nonlinear
spatial filters whose 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 result.

Best-known “median filter”

28
Process of Median filter
Corp region of
neighborhood
10 15 20
Sort the values of
20 100 20 the pixel in our
region
20 20 25
In the M x N mask
the median is
10, 15, 20, 20, 20, 20, 20, 25, 100 M x N div 2 +1

5th

29
Median Filters are quite popular …

For certain types of random noise,


they provide excellent noise reduction
capabilities, with considerably less
blurring than linear smoothing filters
of similar size.
They are particularly effective in the
presence of impulse noise (salt-&-
pepper noise because of its appearance
as white & black dots superimposed on
an image).
30
Result of median filter

Noise from Remove noise by


Glass effect median filter
31
32
Using the 100th percentile results gives us
the max filter, which is useful in finding the
brightest points in the image. The response
of a 3 x 3 max filter is given by
R = max{zk k = 1,2, …, 9}

The 0th percentile filter is the min filter,


used for the opposite purpose.

33
Sharpening Spatial
Filters
The principal objective of
sharpening is to highlight fine detail
in an image or to enhance detail that
has been blurred, either in error or
as an natural effect of a particular
method of image acquisition.
34
Uses of Image Sharpening

Electronic printing
Medical imaging
Industrial inspection
Autonomous guidance in military
systems

35
Image
Blurring Can be accomplished in
spatial domain by
pixel averaging in a
neighbourhood

Averaging analogous to
integration!!

Therefore, logically it can be


concluded that sharpening can be
accomplished by
spatial differentiation
36
Fundamental properties of
Derivatives in a Digital context

We study the behaviour of one dimensional


derivatives in the areas of
constant gray level(flat segments)
 at the onset and end of discontinuities(step and
ramp discontinuities),
along gray-level ramps.
These types of discontinuities can be used to model
noise points, lines, and edges.
37
Definition for a
first derivative

Must be zero in flat segments

Must be nonzero at the onset of a

gray-level step or ramp; and

Must be nonzero along ramps.


38
Definition of the
1st-order derivative

A basic definition of the first-order


derivative of a one-dimensional
function f(x) is

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

39
Definition for a
second derivative

Must be zero in flat areas;

Must be nonzero at the onset and


end of a gray-level step or ramp;
Must be zero along ramps of
constant slope
40
Definition of the
2nd-order derivative

• We define a second-order derivative


as the difference

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

41
42
Analysis
1)The 1st-order derivative is nonzero along the
entire ramp, while the 2nd-order derivative is
nonzero only at the onset and end of the ramp.
2)Edges in an image represent this type (ramp) of
transition. Therefore,
1st make thick edge and 2nd make thin, much finer edges
3)The response at and around the point is much
stronger for the 2nd- than for the 1st-order
derivative.

43
 First-order derivatives generally produce thicker
edges in an images.
 Second-order derivatives have a stronger
response to fine detail (thin lines or isolated
points).
 First-order derivatives generally have a stronger
response to a gray-level step.
 Second-order derivatives produce a double
response at step changes in gray level
44
The approach basically consists of
the following steps:

1.Defining a discrete formulation of the


second-order derivative.
2.Constructing a filter mask based on that
formulation.
45
Isotropic Filters
Rotation invariant

Rotate the
image & then
apply the
filter
Re
su
lt
sa
m
e

Apply the
filter & then
rotate the
result
46
Simplest isotropic derivative operator
Laplacian

It is a function (image) f(x, y) of two


variables, defined as

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

x y
In order to be useful for DIP, this equation
needs to be expressed in discrete form
47
Discrete form of derivative

f(x-1,y) f(x,y) f(x+1,y) 2 f


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

f(x,y-1)

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

f(x,y+1)

48
2-Dimensional Laplacian
• The digital implementation of the
2-Dimensional Laplacian is obtained
by summing 2 components
 2
f  2
f
 f  2  2
2

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

0 1 0
This mask gives an isotropic
1 -4 1
result for rotations in
0 1 0
increments of 90º.

49
Mask used to implement an extension of the
Laplacian previous mask. It includes the diagonal
neighbours.

The mask yields


isotropic results for
increments of 45º

0 1 0 1 1 1

1 -4 1 1 -8 1

0 1 0 1 1 1

1 0 1

0 -4 0

1 0 1
50
Laplacian
(two other implementations)

0 -1 0 -1 -1 -1

-1 4 -1 -1 8 -1

0 -1 0 -1 -1 -1

-1 0 -1

0 4 0

-1 0 -1

51
Implementation
Highlights gray-level
discontinuities in an
image
Laplacian is a
derivative
operator
Deemphasizes regions
with slowly varying gray
levels

This tends to produce images that have


Grayish edge lines & other discontinuities
Dark featureless background
52
Image of the
north pole of the
moon

53
Background features can be “recovered”
while still preserving the sharpening effect
of the Laplacian operator simply by adding
the original & the Laplacian images.

 f ( x, y )   2 f ( x, y ) If the center coefficient is negative


g ( x, y )  
 f ( x , y )   2
f ( x, y ) If the center coefficient is positive

Where f(x, y) is the original image


 2 f ( x, y ) is Laplacian filtered image
g(x, y) is the sharpened image
54
The details in this image is clearer &
sharper than in the original image

55

You might also like