You are on page 1of 37

Indian IInstitute of Inform

mation Technoloogy, Allaahabad

Ed Detection
Edge
D
i

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

Wh are edges
What
d
in
i an image?
i
?
Edges are those places
i an image
in
i
that
th t
correspond to object
b
boundaries.
d i
Edges are pixels where
image brightness
changes abruptly.
Brightness vs. Spatial Coordinates

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

M
More
About
Ab
Ed
Edges
An edge is a property attached to an
i di id l pixel
individual
i l andd is
i calculated
l l t d from
f
the
th
image function behavior in a neighborhood
off th
the pixel.
i l
It is a vector variable (magnitude of the
gradient, direction of an edge) .

Indian IInstitute of Inform


mation Technoloogy, Allaahabad

I
Image
T
To Edge
Ed Map
M

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

Ed Detection
Edge
D
i
Edge information in an image is found by looking
at the relationship a pixel has with its
neighborhoods.
If a pixels
pixel s gray-level
gray level value is similar to those
around it, there is probably not an edge at that
p
point.
If a pixels has neighbors with widely varying gray
levels, it may present an edge point.

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

Ed Detection
Edge
D
i
An edge is a boundary between an object

and the background, and indicates the


boundary between overlapping objects.
Edges form the outline of an object, so if the
edges are identified in an image accurately,
then all the objects can be located and basic
properties such as area,
area perimeter can be
measured.
Edge
dge detection
de ec o iss based
b sed on
o thee relationship
e o s pa
pixel has with its neighbors.

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

Ed Detection
Edge
D
i
Edges, in an image are defined as locations
where there is a significant variation in the
gray level or color of pixel in some direction.
Edge detection extracts and localizes points
(pixels) around which a large change in
age bbrightness
g t ess has
as occurred.
occu ed.
image
This can help in the process of
segmentation

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

T di i l Approaches
Traditional
A
h
Ideal Step Edge :(The most common definition of an edge)
In 1-d the edge is simply a change in gray
level occurring at one specific location
(fig.1a).
The greater the change in the level, the
easier the edge is to detect.

Indian IInstitute of Inform


mation Technoloogy, Allaahabad

S
Step
Edge
d Detection
i

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

P bl
Problems
in
i Edge
Ed Detection
D
i
Problems:1)Because of digitization:-The image may be
p in such a wayy so that change
g in ggray
y
sampled
level may extend across some number of
pixels. Fig
p
g 1b-d.
2)Because of noise:-Due to factors such as
light intensity,
intensity type of camera and lens,
lens
motion, temperature, dust and others.

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

Noise
Two types of noise are of interest in image analysis:1) Signal independent:-noise
independent:-noise is a random set of gray levels,
levels
statistically independent of the data. It occurs during
electronically transmission of image. If A is a perfect
i
image
and
d N iis the
th noise
i that
th t occurs d
during
i
transmission, then the final image B is
B=A+N
2) Signal-dependent noise:- In this the level of the noise
value at each point in the image is a function of the
grey level
l l there.
h

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

Ed Detection
Edge
D
i Methods
M h d
Many are implemented with convolution
mask and based on discrete approximations
to differential operators.
Differential operations measure the rate of
change in the image brightness function.
Some operators return orientation
information. Other only return information
bou thee existence
e s e ce of
o an edge at each
e c point.
po .
about

v = f(x,y)

Indian IInstitute of Inform


mation Technoloogy, Allaahabad

A 2D grayvalue - image is
a 2D -> 1D function

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

Derivative Operators
An operator, that is sensitive to change in gray level will operate as
an edge detector- A derivative operator does this.
Interpretation of derivative:- The rate of change of function. The
rate of change of the gray levels in an image is large near an edge
and small in constant areas.
In images are 2-D, so level changes are considered in many
directions. For this reason partial derivatives of the image are used
with respect to the principal directions x and y.
Let A (x, y) be an image then the gradient is defined as:
( / x,, A / y)
y)
A ((x ,y) = (A

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

G di operators
Gradient
Because image is discrete, the derivative at a pixel is approximated by
the difference in gray levels over some local region.
The simplest approximation is the operator 1:

x1A(x, y) = A(x, y) A(x-1, y)


x2A(x,
A(x y) = A(x
A(x, y) A(x,
A(x yy-1)
1)
Problem with this operator:- It does not compute the gradient at the
point (x
(x, y)
y), but at (x-1/2
(x 1/2, yy-1/2)
1/2)
Assumption:- the grey levels vary linearly between the pixels.

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

G di operators
Gradient
A better choice for an approximation is
x2 A(x,
A( y)) = A(
A(x+1,
+1 y)) A(x-1
A( 1 ,y))
y2 A(x,
A(x y) = A(x,
A(x y+1) A(x,
A(x y-1)
This operator is symmetrical with respect to the pixel (x,
y). It does not consider the value of the pixel at (x, y).
The edge response is given by:
Gmag = ((A

x)2 + (A y)2)

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

G di operators
Gradient
and the direction of the edge is approximately:
Gdir = atan (A y) ( A x)
Edge pixel- which exceeds the threshold
value

Indian IInstitute of Inform


mation Technoloogy, Allaahabad

G di operators examples
Gradient
l

Indian IInstitute of Inform


mation Technoloogy, Allaahabad

E
Examples
l

Indian IInstitute of Inform


mation Technoloogy, Allaahabad

E
Examples
l

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

Measures of Performance of Edge


Detection Schemes
False Positive
False Negative
g
Using Function (Pratt 1978)
E1 =(1/(1+d(i)
( /(
d(i)2)) / max(I
( A,II)
IA = the number of edge pixels found by the edge detector
II= the number of edge pixels in the test image
d(i)=the distance between the actual ith pixel and the one
found by the edge detector
is
i usedd for
f scaling
li

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

M
Measures
off P
Performance
f
Evaluation scheme based on local edge coherence (Kitchen
and Rosenfeld))
(a) It measures how well an edge pixel is continued on the
left; this function is
L(k) =a(d,dk) a(k/4,d+/2) if neighbor k is an edge pixel
0
otherwise
where
h d is
i the
th edge
d direction
di ti att the
th pixel
i l being
b i tested
t t d
d0 is the edge direction at its neighbor to the right
d1 is the direction of the upper
upper-right
right neighbor,
neighbor and so on
Counterclockwise about the pixel involved
a= the measure of the angular difference between any two

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

Measures
M
a(,) = -|-|
(b) A similar function measures directional continuity on the
right of the pixel being evaluated:
R(k) = a(d,dk) a(k/4,d+/2) if neighbor k is an edge
pixel
0
otherwise
(c) C= Overall continuity measure
= average(L(k), R(k))
(d) Then measure of thinness (T) is applied.
(e) The overall evaluation of the edge detector is:
(f)
E2 = C + (1-) T

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

Template-Based
Template
Based Edge Detection
This uses a small, discrete template as a model of an edge
p
instead of usingg a derivative operator.
Exampes:(a) Sobel Edge Detector
(b) Kirsch Edge Detector

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

P i Operator
Prewitt
O

1 1 1
y = 0 0 0
1 1 1

1 0 1
x = 1 0 1
1 0 1

x2 + y2

y
tan
x
1

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

S b l Operator
Sobel
O
Similar to the Prewitt, with different mask
coefficients:
1 2 1
0
0
y = 0
1
2
1

Edge
g Magnitude
g
=

1 0 1
x = 2 0 2
1 0 1

x +y
2

Edge
g Direction

y
= tan x

1

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

Ki h C
Kirsch
Compass Masks
M k
Taking a single mask and rotating it to 8
major compass orientations: N,
N NW,
NW W,
W SW,
SW
S, SE, E, and NE.
The edge magnitude = The maximum value
found by the convolution of each mask with
tthee image.
age.
The edge direction is defined by the mask
produces
oduces thee maximum
u magnitude.
g ude.
that p

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

Ki h Compass
Kirsch
C
Masks
M k (Cont.)
(C
)
The Kirsch masks are defined as follows:
5
5
5
5 3
3 3 5
3 5
5
5
N = 3 0 5 W = 3 0
5 S = 3 0 3 E = 5
0 3
3 3 5
3 3 3
3 3 3
3 3 3
5 3 3
3 3 3
3 3 3
3 3 5
NW = 5 0 3SW = 5
0 3SE = 3 0 3 NE = 3 0 5
5
5
5 3
5
5
5 3 3
3 5 5

EX: If NE pproduces the maximum value,, then the


edge direction is Northeast

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

Ki h Ed
Kirsch
Edge Detector
D
These masks are to observe the grey level change near an edge having
various orientations, rather than approximation to the gradient.
There
There are one mask for each of eight compass directions.
For example, a large response to mask K0 implies a vertical edge
(horizontal gradient) at the pixel corresponding to the center of the
mask.
Method:To find the edges, an image I is convolved with all of the masks at each
pixel position
position. The response of the operator at a pixel is the maximum
of the responses of any of the eight masks. The direction of the edge
pixel is quantized into eight possibilities and is /4 *I where I is the
g the largest
g response.
p
number of the mask having
Looks for edges in both horizontal and vertical directions, then combine
the information into a single metric.

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

R bi
Robinson
Compass
C
Masks
M k
Similar to the Kirsch masks, with mask
coefficients
ffi i t off 0,
0 1,
1 andd 2:
2
1 0 1
N = 2 0 2
1 0 1

1 2
2
1
0
0
1
2 1
W = 1 0 1 S = 0
0
0 E = 1 0 1
2 1 0
1 2 1
0 1 2

1 0 1
0 1 2
1 2 1
2 1 0
NW = 2 0 2 SW = 1 0 1 SE = 0
0
0 NE = 1 0 1
1 0 1
2 1
1
0
0
1 2
2
1

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

Sometimes we are interested only in edge magnitudes without


regard to their orientations.
The Laplacian may be used.
The Laplacian has the same properties in all directions and is
therefore invariant to rotation in the image.
g

The Laplace operator is a very popular operator


approximating the second derivative which gives the
gradient magnitude only.

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

L l i Operators
Laplacian
O
Edge magnitude is approximated in digital
i
images
by
b a convolution
l ti sum.
The sign of the result (+ or -) from two
adjacent pixels provide edge orientation and
tells us which side of edge brighter

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

L l i Operators
Laplacian
O
(Cont.)
(C
)
Masks for 4 and 8 neighborhoods
0 1 0
1 4 1

0 1 0

1 1 1
1 8 1

1 1 1

1 2 1
2 4 2

1 2 1

2 1 2
1 4 1

2 1 2

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

C
Comparison
i
Sobel and Prewitt methods are very effectively
providing good edge maps.
Kirsch
Ki h andd Robinson
R bi
methods
th d require
i more time
ti for
f
calculation and their results are not better than the
ones pproduced by
y Sobel and Prewitt methods.
Roberts and Laplacian methods are not very good
as expected.

Indian Institute of Inform


mation T
Technoloogy, Allaahabad

Gradient operators can be divided into three categories


I. Operators approximating derivatives of the image function
using differences.
rotationally
rotationall invariant
in ariant (e.g.,
(e g Laplacian) need one convolution
con ol tion
mask only. Individual gradient operators that examine small
local neighborhoods are in fact convolutions and can be
expressed by convolution masks.
approximating
approximating first derivatives use several masks, the
orientation is estimated on the basis of the best matching of
several simple patterns. Operators which are able to detect
edge direction.
direction Each mask corresponds to a certain direction.
direction

Indian Institute of Inform


mation T
Technoloogy, Allaahabad

II. Operators based on the zero crossings of the image function


second derivative (e.g., Marr-Hildreth or Canny edge detector).
III. Operators which attempt to match an image function to a
parametric model of edges. Parametric models describe edges
more precisely than simple edge magnitude and direction and
are much more computationally intensive.
intensive
The categories II and III will be covered in the next lecture

Indian IInstitute of Inform


mation T
Technoloogy, Allaahabad

AQ
Quick
i kN
Note
Matlabs image processing toolbox provides edge
function to find edges in an image:
I = imread('rice.tif');
BW1 = edge(I,'prewitt');
BW2 = edge(I,'canny');
imshow(BW1)
figure imshow(BW2)
figure,

Edge function supports six different edge-finding


methods: Sobel, Prewitt, Roberts, Laplacian
p
of
Gaussian, Zero-cross, and Canny.

You might also like