EDGE DETECTION
INEL 6088 - Computer Vision
Davies Ch. 5, Jain et. al. Ch. 5
- Sec. 4.2 Szelinski
EDGE DETECTION INEL 6088 - Computer Vision Davies Ch. 5, Jain et. - - PowerPoint PPT Presentation
EDGE DETECTION INEL 6088 - Computer Vision Davies Ch. 5, Jain et. al. Ch. 5 Sec. 4.2 Szelinski ideal ~real 2 Edge point point at which the local intensity changes significantly Edge fragment edge (point) and orientation Edge
INEL 6088 - Computer Vision
2
ideal ~real
Edge point – point at which the local intensity changes significantly Edge fragment – edge (point) and orientation Edge detector – produces a set of edges (points or fragments) Edge linking – orders a list of edges Contour – list of edges Edge following – searching the (input) image to determine contours
4
Edge detector produces:
5
EDGE DETECTION USING GRADIENT
G[f(x,y)]=[Gx Gy]T Gx = δf/δx ≈ f[i,j+1]-f[i,j] « gradient at [i, j+½] Gy = δf/δy ≈ f[i+1,j]-f[i,j] « gradient at [i+½, j] To get the gradient at the same point [i+½, j+½], use: Simple way
6
Steps:
Roberts: P5 = |P5 - P9| + |P8 – P6|
Sobel: c = mult. by 2 Prewitt: Sobel with c = 1
2 1 15 33 29 3 2 11 28 60 5 25 32 40 41 4 20 33 43 41 4 2 19 27 35 1 2 1
2 5 19 64 110 91 29 3 8 18 52 127 148 60 3 30 68 65 43 31 12 2 22 60 77 33 -23 -19
C = Sy = gx=conv2(C,Sy) =
Fr,c = fr,c ∗ gr,c =
1
1
fi,jgr−i,c−j
5 + 2*25 + 32 - (2 + 2 + 15) = 68
Sx = Sy’ 2 1 13 32 14 -33 -29 7 4 34 90 77 -94 -118 13 30 56 99 121 -129 -190 18 72 90 79 75 -151 -183 19 67 98 86 41 -153 -158 13 24 58 73 40 -97 -111 4 2 15 25 16 -27 -35 gy=conv2(Sy, C)= G(i,j)=sqrt(gx2 + gy2) 2.8284 5.0990 23.0217 71.5542 110.8873 96.7988 41.0122 7.6158 8.9443 38.4708 103.9423 148.5194 175.3283 132.3782 13.3417 42.4264 88.0909 118.4314 128.4134 132.6725 190.3786 18.1108 75.2861 108.1665 110.3177 81.9390 152.7416 183.9837 19.0263 71.5122 114.9087 106.0189 60.8769 155.0290 158.1139 13.9284 38.4187 97.2008 148.2228 164.9242 158.2214 118.3300 5.6569 10.1980 30.8869 71.5122 109.1788 100.6876 49.4975
3 5 23 72 111 97 41 8 9 38 104 149 175 132 13 42 88 118 128 133 190 18 75 108 110 82 153 184 19 72 115 106 61 155 158 14 38 97 148 165 158 118 6 10 31 72 109 101 49 uint8 version of G= 0 0 0 0 1 0 0 0 0 0 1 1 1 1 0 0 0 1 1 1 1 0 0 1 1 0 1 1 0 0 1 1 0 1 1 0 0 0 1 1 1 1 0 0 0 0 1 0 0 Using a threshold of 0.4 to detect the edge:
10
11
12
13
14
EDGE DETECTORS THAT USE THE SECOND DERIVATIVE
15
LAPLACIAN
16
17
18
SECOND DIRECTIONAL DERIVATIVE
Second derivative computed in the direction of the
gradient
Implement using the formula:
19
Problem with Laplacian and second-derivative-operator:
crossing in the second derivative. Solution: Filter out noise before edge enhancement
large peak (i.e. above some threshold) in the first derivative
resolution
20
Mexican-hat Operator The output of the LoG operator, h(x,y) is given by:
h(x, y) = r2[g(x, y) ? f(x, y)] h(x, y) = [r2g(x, y)] ? f(x, y) r2g(x, y) = x2 + y2 22 4 exp ✓ x2 + y2 22 ◆
21
a gaussian filter To obtain real edges, it might be necessary to combine information from filters of different sizes. The problem of combining edges obtained from different size operators still remains.
22
23
Smoothing causes blurring large σ: better noise filtering but more blurring – can cause edge merging By applying filters of different sizes and analysing the results, better edge detection can be accomplished.
24
25
Facet model: fit a function only in the local neighborhood of each pixel.
26
27
28
29
The angle may be chosen to be the angle of the approximating plane:
2 + k2 3
2 + k2 3
θ (x0, y0) = 2(3k7 cos2 θ + 2k8 sin θ cos θ + k9 sin2 θ)x0
f 0
θ(x, y)
= ∂f ∂x cos θ + ∂f ∂y sin θ f 00
θ (x, y)
= ∂2f ∂x2 cos2 θ + 2 ∂2f ∂x∂y cos θ sin θ + ∂2f ∂y2 sin2 θ
30
There is an edge at (x0,y0) if for some ρ, | ρ |< ρ0 where ρ0 is the length of the side of a pixel,
x0 = ρ cos θ y0 = ρ sin θ f 00
θ (x0, y0)
= 6(k10 sin3 θ + k9 sin2 θ cos θ + k8 sin θ cos2 θ + k7 cos3 θ)ρ +2(k6 sin2 θ + k5 sin θ cos θ + k4 cos2 θ) = Aρ + B
31
32
33
Let I[i,j] be the image. First use Gaussian smoothing:
S[i,j]=G[i,j;σ]*I[i,j]
Find approx. gradient using 2×2 first-diff. approx.
x direction:
P[i,j]=(S[i,j+1]-S[i,j]+S[i+1,j+1]-S[i+1,j])/2
y direction:
Q[i,j]=(S[i,j]-S[i+1,j]+S[i,j+1]-S[i+1,j+1])/2
34
Magnitude and orientation: rectangular to polar
conversion:
M[I,j]=√(P[i,j]2+Q[i,j]2) θ[i,j] = arctan(Q[i,j]/P[i,j])
Non-maxima Suppression
Thins the ridges of gradient magnitude to one pixel Passes a 3x3 neighborhood across the magnitude
array M[I,j] and replace pixels with 0 if not greater than neighbors
35
36
Thresholding
Apply two threshold t1 and t2, with t2 = 2*t1 This produces two threshold images T1 & T2 T2 will have fewer edges, but might have gaps When the end of a contour in T2 is reached, look into
T1 at the 8-neighboring locations to see if there are further edge points that can be linked to the contour.
37
38
39
40
Edge following: scan image looking for strong edge extend the edge in the proper direction by
looking at neighboring edges
link if directions are compatible look at large neighborhood to fill in missing
edges
41
Consider the spatial image gradient, [Ex, Ey]T (the subscripts indicate par- tial differentiation, e.g. Ex =
∂E ∂x ). Consider a generic image point p and a
neighborhood Q of p, and a matrix C defined as C = ✓ P E2
x
P ExEy P ExEy P E2
y
◆ where the sums are taken over Q. A rotation of the coordinate axes can diago- nalized the matrix, C = ✓ λ1 λ2 ◆
λ1 gives the direction of the edge
the edges.
Corner Detection
Corner detection algorithm
– threshold t on λ2 (smallest eigenvalue) – size N of square window (neighborhood), 2N + 1