Fundamentals of Image Processing: Lecture #7 Edge Detection
Fundamentals of Image Processing: Lecture #7 Edge Detection
0 0 1 0 0
0 1 1 1 0
1 1 1 1 1
0 1 1 1 0
0 0 1 0 0
Introduction (cont.)
1, 0, 0, 0, 0, 0, 0, 0, 0 +
0, 1, 0, 0, 0, 0, 0, 0, 0
0, 0, 1, 0, 0, 0, 0, 0, 0
0, 0, 0, 1, 0, 0, 0, 0, 0
0, 0, 0, 0, 1, 0, 0, 0, 0
0, 0, 0, 0, 0, 1, 0, 0, 0
0, 0, 0, 0, 0, 0, 1, 0, 0
0, 0, 0, 0, 0, 0, 0, 1, 0
0, 0, 0, 0, 0, 0, 0, 0, 1
Introduction (cont.)
+
0, 0, 0, 0, 0
0, 0, 0, 0, 0
- 1, - 1, 2, 0, 0
0, 0, 0, 0, 0
0, 0, 0, 0, 0,
Introduction (cont.)
+
0, 0, - 1, 0, 0
0, 0, - 1, 0, 0
0, 0, 4, 0, 0
0, 0, - 1, 0, 0
0, 0, - 1, 0, 0
Introduction (cont.)
+
- 1, 0, 0, 0, 0
0, - 2, 0, 0, 0
0, 0, 6, 0, 0
0, 0, 0, - 2, 0
0, 0, 0, 0, - 1,
Introduction (cont.)
- 1, - 1, - 1
- 1, 8, - 1
- 1, - 1, - 1
Introduction (cont.)
To sharpen the image is very similar to finding edges, The result will be
a new image where the edges are enhanced, making it look sharper.
For example, the center value of the edge detection filter from the
previous example, is incremented with 1. The result will be an image
with the same brightness as the original, but sharper
- 1, - 1, - 1
- 1, 9, - 1
- 1, - 1, - 1
Introduction (cont.)
+
- 1, - 1, - 1, - 1, - 1
- 1, 2, 2, 2, - 1
- 1, 2, 8, 2, - 1
- 1, 2, 2, 2, - 1
- 1, - 1, - 1, - 1, - 1
What is edge detection?
Edge detection is a fundamental image processing
operation used in many computer vision solutions.
Goal of edge detection algorithms: to find the most relevant
edges in an image or scene.
These edges should then be connected into meaningful lines
and boundaries, resulting in a segmented image containing
two or more regions.
Subsequent stages in a machine vision system will use the
segmented results for tasks such as object counting,
measuring, feature extraction, and classification.
What is edge detection? (cont.)
The
influence of
noise
Basic concepts (cont.)
In MATLAB: edge
Background: Derivatives (remember?)
First-order derivative
f
f '( x) f ( x 1) f ( x)
x
Second-order derivative
2
f
2
f ( x 1) f ( x 1) 2 f ( x)
x
Characteristics of First and Second Order Derivatives
R 1z1 2 z2 9 z9
Detection of Isolated Points
The Laplacian
2 2
2 f f
f ( x, y ) 2 2
x y
f ( x 1, y ) f ( x 1, y ) f ( x, y 1) f ( x, y 1)
4 f ( x, y )
1 if | R( x, y ) | T 9
R wk zk
g ( x, y )
0 otherwise k 1
First-order derivative edge detection
Roberts:
First-order derivative edge detection (cont.)
Prewitt operators:
First-order derivative edge detection (cont.)
Sobel operators:
First-order derivative edge detection (cont.)
Prewitt operator
J = imread('bw_scissors.png');
Jt = imcomplement(J);
Jt = Jt .* 0.5;
Ju = imcomplement(Jt);
Jd = im2double(Ju);
hy = fspecial('prewitt')
hx = hy'
J8 = imfilter(Jd,hy);
J7 = imfilter(Jd,hx);
Jx = mat2gray(J7);
Jy = mat2gray(J8);
imshow(Jy), figure, imshow(Jx)
J10 = abs(J7) + abs(J8);
Jxy = mat2gray(J10);
figure, imshow(Jd), figure, imshow(Jxy)
First-order derivative edge detection (cont.)
Prewitt operator
First-order derivative edge detection (cont.)
Sobel operator
J = imread(’Figure14_05_a.png');
Jd = im2double(J);
hy = fspecial('sobel')
hx = hy'
J1 = imfilter(Jd,hy);
J2 = imfilter(Jd,hx);
imshow(J1)
J1c = imcomplement(J1); figure, imshow(J1c)
J2c = imcomplement(J2); figure, imshow(J2c)
J3 = abs(J1) + abs(J2);
J3c = imcomplement(J3); figure, imshow(J3c)
First-order derivative edge detection (cont.)
Sobel operator
First-order derivative edge detection (cont.)
In MATLAB:
h = fspecial('laplacian',0);
J = edge(I,'zerocross',t,h);
Second-order derivative edge detection (cont.)
Laplacian and
zero-cross
Second-order derivative edge detection (cont.)
J = imread('Figure14_05_a.png');
J1 = edge(J,'log');
imshow(imcomplement(J1))
J2 = edge(J,'log',[],1);
figure, imshow(imcomplement(J2))
J3 = edge(J,'log',[],3);
figure, imshow(imcomplement(J3))
Second-order derivative edge detection (cont.)
Laplacian
of Gaussian
(LoG)
Marr-Hildreth edge detector
x2 y 2
G ( x, y ) e , : space constant.
2 2
The
Laplacian of Gaussian (LoG)
Marr- 2 2 G ( x, y ) 2G ( x, y )
G ( x, y ) 2
Hildreth x y 2
edge
x 2 2 y x 2y
2 2 2 2
x y
detector 2e 2 e 2
x y
2 x2 y 2 2 x2 y 2
x 1 2 2
y 1 2 2
4 2 e 4 2 e
2 2 2 x2 y 2
x y 2 2
4 e
Marr-Hildreth edge detector (cont.)
Marr-Hildreth Algorithm
g ( x, y ) G ( x, y ) f ( x, y )
2
Marr-Hildreth edge detector (cont.)
The Canny edge detector
Optimal for step edges corrupted by white
noise.
The Objective
Example
14.5:
Edge linking and boundary detection
[H,T,R] = ...
hough(BW,'RhoResolution',0.5,'ThetaResolution',0.5);
xlabel('\theta'), ylabel('\rho');
axis on, axis normal, hold on;
colormap(gray);
The Hough transform (cont.)
Example 14.6
The Hough transform (cont.)
In MATLAB:
The IPT also includes two useful companion functions for
exploring and plotting the results of Hough Transform
calculations:
houghpeaks: identifies the k most salient peaks in the Hough
transform results, where k is passed as a parameter.
houghlines: draws the lines associated with the highest peaks
on top of the original image.
The Hough transform (cont.)
Example 14.7
(PIVPUM)
Summary