Professional Documents
Culture Documents
Dip 06 55
Dip 06 55
Using
Arithmetic /
Logic Operators
2
When dealing with logic operations on
gray-level images, pixel values are
processed as strings of binary numbers
3
4
NOT
Operation
8 bit black 8 bit white
pixel pixel
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
10
Enhancement techniques
based on the
pixels of an image are
often referred to as
Spatial filtering
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.
15
16
Note: Linear filtering
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
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.
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
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
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.
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 …
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!!
f
f ( x 1) f ( x)
x
39
Definition for a
second derivative
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:
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
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,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.
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
53
Background features can be “recovered”
while still preserving the sharpening effect
of the Laplacian operator simply by adding
the original & the Laplacian images.
55