5.edgedetection [compatibility mode]
DESCRIPTION
IVPTRANSCRIPT
Indian I
Wh d i i ?
Institute
What are edges in an image?
of Inform
Edges are those places i i th tm
ation T
in an image that correspond to object b d i
Technolo
boundaries.Edges are pixels where ogy, A
lla
image brightness changes abruptly. ahabad
Brightness vs. Spatial Coordinates
Indian I
M Ab Ed
Institute
More About Edges
of Inform
An edge is a property attached to an i di id l i l d i l l t d f thm
ation T
individual pixel and is calculated from the image function behavior in a neighborhood
f th i l
Technolo
of the pixel. It is a vector variable (magnitude of the ogy, A
lla
gradient, direction of an edge) .
ahabad
Indian I
Ed D i
Institute
Edge Detection
of Inform
Edge information in an image is found by looking at the relationship a pixel has with itsm
ation T
at the relationship a pixel has with its neighborhoods.If a pixel’s gray-level value is similar to thoseTechnolo
If a pixel s gray level value is similar to those around it, there is probably not an edge at that point.ogy, A
lla
pIf a pixel’s has neighbors with widely varying gray levels, it may present an edge point.ahabad
Indian I
Ed D i
Institute
Edge Detection
of Inform
An edge is a boundary between an object and the background, and indicates them
ation T
and the background, and indicates the boundary between overlapping objects.Edges form the outline of an object, so if the Technolo
edges are identified in an image accurately, then all the objects can be located and basic properties such as area perimeter can beogy, A
lla
properties such as area, perimeter can be measured.Edge detection is based on the relationship a ahabad
dge de ec o s b sed o e e o s ppixel has with its neighbors.
Indian I
Ed D i
Institute
Edge Detection
of Inform
Edges, in an image are defined as locations where there is a significant variation in them
ation T
where there is a significant variation in the gray level or color of pixel in some direction.Edge detection extracts and localizes pointsTechnolo
Edge detection extracts and localizes points (pixels) around which a large change in image brightness has occurred.ogy, A
lla
age b g t ess as occu ed.This can help in the process of segmentationahabad
segmentation
Indian I
T di i l A h
Institute
Traditional Approaches
of Inform Ideal Step Edge :-mation T
(The most common definition of an edge)
Technolo
In 1-d the edge is simply a change in gray level occurring at one specific location ogy, A
lla
(fig.1a).The greater the change in the level, the ahabad
easier the edge is to detect.
Indian I
P bl i Ed D i
Institute
Problems in Edge Detection
of Inform Problems:-mation T
1)Because of digitization:-The image may be sampled in such a way so that change in gray Technolo
p y g g ylevel may extend across some number of pixels. Fig 1b-d.ogy, A
lla
p g2)Because of noise:-Due to factors such as
light intensity type of camera and lensahabad
light intensity, type of camera and lens, motion, temperature, dust and others.
Indian I NoiseInstitute
Noise
of Inform
Two types of noise are of interest in image analysis:-1) Signal –independent:-noise is a random set of gray levelsm
ation T
1) Signal independent:-noise is a random set of gray levels, statistically independent of the data. It occurs during electronically transmission of image. If A is a perfect i d N i th i th t d i
Technolo
image and N is the noise that occurs during transmission, then the final image B is
B = A + Nogy, Alla
N2) Signal-dependent noise:- In this the level of the noise
value at each point in the image is a function of the l l h
ahabad
grey level there.
Indian I
Ed D i M h d
Institute
Edge Detection Methods
of Inform
Many are implemented with convolution mask and based on discrete approximationsm
ation T
mask and based on discrete approximations to differential operators.Differential operations measure the rate ofTechnolo
Differential operations measure the rate of change in the image brightness function.Some operators return orientationogy, A
lla
Some operators return orientation information. Other only return information about the existence of an edge at each point.ahabad
bou e e s e ce o edge e c po .
Indian I A 2D grayvalue - image isInstitute
A 2D grayvalue image is a 2D -> 1D function
of Inform
v = f(x,y)
mation TTechnoloogy, A
llaahabad
Indian I Derivative OperatorsInstitute
Derivative Operators
of Inform
An operator, that is sensitive to change in gray level will operate as an edge detector- A derivative operator does this.m
ation T
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.Technolo
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.ogy, A
lla
Let A (x, y) be an image then the gradient is defined as:
∆A (x ,y) = (∂A / ∂x, ∂A / ∂y)ahabad
( ,y) ( , y)
Indian I
G di
Institute
Gradient operators
of Inform
Because image is discrete, the derivative at a pixel is approximated by the difference in gray levels over some local region.m
ation T
The simplest approximation is the operator ∆1:
Technolo
Δx1A(x, y) = A(x, y) – A(x-1, y)
Δ A(x y) = A(x y) A(x y 1)
ogy, Alla
Δx2A(x, y) = A(x, y) – A(x, y-1)
Problem with this operator:- It does not compute the gradient at the point (x y) but at (x-1/2 y-1/2)ahabad
point (x, y), but at (x 1/2, y 1/2)Assumption:- the grey levels vary linearly between the pixels.
Indian I
G di
Institute
Gradient operators
of Inform
A better choice for an approximation is Δ A( ) A( +1 ) A( 1 )
mation T
Δx2 A(x, y) = A(x+1, y) – A(x-1 ,y)
Δ A(x y) = A(x y+1) – A(x y-1)Technolo
Δy2 A(x, y) = A(x, y+1) – 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).ogy, Alla
The edge response is given by:
√
ahabad
Gmag = √((∂A ⁄ ∂x)2 + (∂A ⁄∂y)2)
Indian I
G di
Institute
Gradient operators
of Inform
and the direction of the edge is approximately:
mation T Gdir = atan (∂A ⁄∂y) ⁄ ( ∂A ⁄ ∂x)Technolo Edge pixel- which exceeds the threshold ogy, A
lla
value
ahabad
Indian I Measures of Performance of EdgeInstitute
Measures of Performance of Edge Detection Schemes
of Inform
False PositiveFalse Negativem
ation T
gUsing Function (Pratt 1978)
∑( /( d(i)2)) / ( )
Technolo
E1 =∑(1/(1+αd(i)2)) / max(IA,II)IA = the number of edge pixels found by the edge detectorII= the number of edge pixels in the test imageogy, A
lla
II the number of edge pixels in the test imaged(i)=the distance between the actual ith pixel and the one
found by the edge detectori d f li
ahabad
α is used for scaling
Indian I
M f P f
Institute
Measures of Performance
of Inform
Evaluation scheme based on local edge coherence (Kitchen and Rosenfeld)m
ation T
)(a) It measures how well an edge pixel is continued on the
left; this function isTechnolo
L(k) =a(d,dk) a(kπ/4,d+π/2) if neighbor k is an edge pixel0 otherwise
h d i th d di ti t th i l b i t t d
ogy, Alla
where d is the edge direction at the pixel being testedd0 is the edge direction at its neighbor to the rightd1 is the direction of the upper-right neighbor and so onahabad
d1 is the direction of the upper right neighbor, and so onCounterclockwise about the pixel involveda= the measure of the angular difference between any two
Indian I
M
Institute
Measures…
of Inform
a(α,β) = π -|α-β| ⁄ π(b) A similar function measures directional continuity on them
ation T
(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 Technolo
pixel0 otherwise
(c) C= Overall continuity measureogy, Alla
(c) C= Overall continuity measure= average(L(k), R(k))
(d) Then measure of thinness (T) is applied.ahabad
(e) The overall evaluation of the edge detector is:(f) E2 = γC + (1-γ) T
Indian I Template-Based Edge DetectionInstitute
Template Based Edge Detection
of Inform
This uses a small, discrete template as a model of an edge instead of using a derivative operator.m
ation T
g pExampes:-
(a) Sobel Edge DetectorTechnolo
(b) Kirsch Edge Detector
ogy, Allaahabad
Indian I
P i O
Institute
Prewitt Operator
of Informmation T
⎤⎡ 111 ⎤⎡ 101
Technolo ⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡ −−−=
111000111
y⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
−−−
=101101101
x
ogy, Alla
⎦⎣ ⎦⎣
22 yx + ⎥⎦⎤
⎢⎣⎡−
xy1tanahabad
⎦⎣
Indian I
S b l O
Institute
Sobel Operator
of Inform
Similar to the Prewitt, with different mask coefficients:m
ation T
coefficients:
⎥⎤
⎢⎡ −−− 121
⎥⎤
⎢⎡− 101Technolo
⎥⎥⎥
⎦⎢⎢⎢
⎣
=121000y
⎥⎥⎥
⎦⎢⎢⎢
⎣−−=
101202x
ogy, Alla Edge Magnitude = Edge Direction = 22 yx + ⎥⎦
⎤⎢⎣⎡−
xy1tanahabad
g g g ⎥⎦⎢⎣ x
Indian I
Ki h C M k
Institute
Kirsch Compass Masks
of Inform
Taking a single mask and rotating it to 8 major compass orientations: N NW W SWm
ation T
major compass orientations: N, NW, W, SW, S, SE, E, and NE.The edge magnitude = The maximum valueTechnolo
The edge magnitude = The maximum value found by the convolution of each mask with the image.ogy, A
lla
t e age.The edge direction is defined by the mask that produces the maximum magnitude.ahabad
p oduces e u g ude.
Indian I
Ki h C M k (C )
Institute
Kirsch Compass Masks (Cont.)
of Inform
The Kirsch masks are defined as follows:⎤⎡ 533 ⎤⎡ 553 ⎤⎡ 555 ⎤⎡ 355m
ation T ⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
−−−
−−=
533503533
N⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
−−−−−
=333
503553
W⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
−−−−−=
333303
555S
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
−−−−−
=333305355
E
Technolo ⎥⎥⎤
⎢⎢⎡
−−−
= 305335
NW ⎥⎥⎤
⎢⎢⎡
−−−−
= 305333
SW ⎥⎥⎤
⎢⎢⎡
−−−−−
= 303333
SE ⎥⎥⎤
⎢⎢⎡−
−−= 503
533NEogy, A
lla EX: If NE produces the maximum value, then the
⎥⎥⎦⎢
⎢⎣ −− 335 ⎥
⎥⎦⎢
⎢⎣ −355 ⎥
⎥⎦⎢
⎢⎣ 555 ⎥
⎥⎦⎢
⎢⎣− 553
ahabad
p ,edge direction is Northeast
Indian I
Ki h Ed D
Institute
Kirsch Edge Detector
of Inform
These masks are to observe the grey level change near an edge having various orientations, rather than approximation to the gradient.
There are one mask for each of eight compass directions.mation T
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.Technolo
mask.Method:-To find the edges, an image I is convolved with all of the masks at each
pixel position The response of the operator at a pixel is the maximumogy, Alla
pixel 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 number of the mask having the largest response.ahabad
g g pLooks for edges in both horizontal and vertical directions, then combine
the information into a single metric.
Indian I
R bi C M k
Institute
Robinson Compass Masks
of Inform
Similar to the Kirsch masks, with mask ffi i t f 0 1 d 2m
ation T
coefficients of 0, 1, and 2:
⎥⎤
⎢⎡−
202101
N ⎥⎤
⎢⎡
101210
W ⎥⎤
⎢⎡
000121
S ⎥⎤
⎢⎡
101012
E
Technolo
⎥⎥⎥
⎦⎢⎢⎢
⎣−−=
101202N
⎥⎥⎥
⎦⎢⎢⎢
⎣ −−−=
012101W
⎥⎥⎥
⎦⎢⎢⎢
⎣ −−−=
121000S
⎥⎥⎥
⎦⎢⎢⎢
⎣ −−−=
210101E
⎤⎡ 101 ⎤⎡ 210 ⎤⎡ 121 ⎤⎡ 012
ogy, Alla ⎥
⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
−−−
=101202101
NW⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡−−−
=012101210
SW⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡ −−−=
121000121
SE⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡−
−−=
210101012
NE
ahabad
⎦⎣ ⎦⎣ ⎦⎣ ⎦⎣
Indian I •Sometimes we are interested only in edge magnitudes withoutInstitute
•Sometimes we are interested only in edge magnitudes without regard to their orientations. •The Laplacian may be used. of Inform
•The Laplacian has the same properties in all directions and is therefore invariant to rotation in the image. m
ation T
g
Technolo •The Laplace operator is a very popular operator ogy, Alla
approximating the second derivative which gives the gradient magnitude only.
ahabad
Indian I
L l i O
Institute
Laplacian Operators
of Inform
Edge magnitude is approximated in digital i b l tim
ation T
images by a convolution sum. The sign of the result (+ or -) from two Technolo
adjacent pixels provide edge orientation and tells us which side of edge brighterogy, A
llaahabad
Indian I
L l i O (C )
Institute
Laplacian Operators (Cont.)
of Inform
Masks for 4 and 8 neighborhoods ⎤⎡ 010 ⎤⎡ 111
mation T ⎥
⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
−−−
−
010141
010
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
−−−−−−−−
111181111
Technolo
⎦⎣ ⎦⎣
ogy, Alla
⎥⎥⎤
⎢⎢⎡
−−−
242121
⎥⎥⎤
⎢⎢⎡ −−
141212
ahabad
⎥⎥⎦⎢
⎢⎣ − 121
242⎥⎥⎦⎢
⎢⎣ −− 212
141
Indian I
C i
Institute
Comparison
of Inform
Sobel and Prewitt methods are very effectively providing good edge maps.Ki h d R bi th d i ti fm
ation T
Kirsch and Robinson methods require more time for calculation and their results are not better than the ones produced by Sobel and Prewitt methods.Technolo
p yRoberts and Laplacian methods are not very good as expected. ogy, A
llaahabad
Indian IInstitute
•Gradient operators can be divided into three categories
of Inform
I. Operators approximating derivatives of the image function using differences. rotationall in ariant (e g Laplacian) need one con ol tionm
ation T
•rotationally invariant (e.g., Laplacian) need one convolution mask only. Individual gradient operators that examine small local neighborhoods are in fact convolutions and can be Technolo
expressed by convolution masks.
•approximating first derivatives use several masks, theogy, Alla
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 Each mask corresponds to a certain direction
ahabad
edge direction. Each mask corresponds to a certain direction.
Indian IInstitute of Inform
II. Operators based on the zero crossings of the image function second derivative (e.g., Marr-Hildreth or Canny edge detector). m
ation T III. Operators which attempt to match an image function to a Technolo
parametric model of edges. Parametric models describe edges more precisely than simple edge magnitude and direction and are much more computationally intensiveogy, A
lla
are much more computationally intensive.
The categories II and III will be covered in the next lecture ahabad
Indian I
A Q i k N
Institute
A Quick Note
of Inform
Matlab’s image processing toolbox provides edge function to find edges in an image:m
ation T
function to find edges in an image:I = imread('rice.tif');
BW1 = edge(I,'prewitt');Technolo
BW2 = edge(I,'canny');imshow(BW1)figure imshow(BW2)ogy, A
lla
figure, imshow(BW2)Edge function supports six different edge-finding methods: Sobel, Prewitt, Roberts, Laplacian of ahabad
pGaussian, Zero-cross, and Canny.