0% found this document useful (0 votes)
11 views

L25 Segmentation2

The document discusses various techniques for edge detection in images, including calculating the image gradient, gradient operators like Roberts, Prewitt and Sobel, and more advanced techniques such as the Marr-Hildreth and Canny edge detectors. The Canny edge detector aims to have a low error rate and well-localized edge points, and works by smoothing the image, calculating the gradient, and applying non-maximum suppression and hysteresis thresholding.

Uploaded by

Karminder Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

L25 Segmentation2

The document discusses various techniques for edge detection in images, including calculating the image gradient, gradient operators like Roberts, Prewitt and Sobel, and more advanced techniques such as the Marr-Hildreth and Canny edge detectors. The Canny edge detector aims to have a low error rate and well-localized edge points, and works by smoothing the image, calculating the gradient, and applying non-maximum suppression and hysteresis thresholding.

Uploaded by

Karminder Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Afdeling Toegepaste Wiskunde / Division of Applied Mathematics

Image segmentation (10.2.5 to 10.2.6) SLIDE 1/19

10.2.5 Basic edge detection

The image gradient and its properties


Definition ∂f
 
gx  ∂x 
∇f = =


gy ∂f 
∂y
Magnitude
 2  2
1/2
∂f ∂f
∇f = mag(∇f) = [gx2 + gy2]1/2 = +
∂x ∂y

Direction  
−1 gy
α(x, y) = tan
gx

The direction of an edge at (x, y) is perpendicular to the direction of the


gradient vector at that point
Afdeling Toegepaste Wiskunde / Division of Applied Mathematics
Image segmentation (10.2.5 to 10.2.6) SLIDE 2/19

Example

 
−2 √
∇f = ; M(x, y) = 2 2; α(x, y) = −45◦
2

(135◦ in positive direction wrt x-axis)


Afdeling Toegepaste Wiskunde / Division of Applied Mathematics
Image segmentation (10.2.5 to 10.2.6) SLIDE 3/19

Gradient operators

∂f (x, y) ∂f (x, y)
gx = = f (x + 1, y) − f (x, y) gy = = f (x, y + 1) − f (x, y)
∂x ∂y

∂f (x, y) ∂f (x, y)
Roberts: gx = = (z9 − z5) gy = = (z8 − z6)
∂x ∂y

Prewitt: gx = (z7 + z8 + z9) − (z1 + z2 + z3) gy = (z3 + z6 + z9) − (z1 + z4 + z7)

Sobel: gx = (z7 + 2z8 + z9) − (z1 + 2z2 + z3) gy = (z3 + 2z6 + z9) − (z1 + 2z4 + z7)
Afdeling Toegepaste Wiskunde / Division of Applied Mathematics
Image segmentation (10.2.5 to 10.2.6) SLIDE 4/19

Convenient approximation:

M(x, y) ≈ |gx| + |gy |


Afdeling Toegepaste Wiskunde / Division of Applied Mathematics
Image segmentation (10.2.5 to 10.2.6) SLIDE 5/19

Masks for detecting diagonal edges


Afdeling Toegepaste Wiskunde / Division of Applied Mathematics
Image segmentation (10.2.5 to 10.2.6) SLIDE 6/19

Example 10.6

Angle info plays key


supporting role in
Canny edge detection
Afdeling Toegepaste Wiskunde / Division of Applied Mathematics
Image segmentation (10.2.5 to 10.2.6) SLIDE 7/19

Result with prior smoothing

Diagonal edge detection


Afdeling Toegepaste Wiskunde / Division of Applied Mathematics
Image segmentation (10.2.5 to 10.2.6) SLIDE 8/19

Combining the gradient with thresholding


Afdeling Toegepaste Wiskunde / Division of Applied Mathematics
Image segmentation (10.2.5 to 10.2.6) SLIDE 9/19

10.2.6 More advanced techniques for edge detection

The Marr-Hildreth edge detector [1980]

• Image should be smoothed first (to reduce noise)


• Larger operators should be used for larger images
• Zero-crossings of second derivative should be exploited
• The Laplacian of a Gaussian (LoG) operator is therefore empolyed
2-D Gaussian operator:
2 2
− x +y
G(x, y) = e 2σ 2 ... (1)

Laplacian of Gaussian (LoG)


2 2 2
2 2
2 x + y − 2σ − x +y
∇ G(x, y) = e 2

σ4
Afdeling Toegepaste Wiskunde / Division of Applied Mathematics
Image segmentation (10.2.5 to 10.2.6) SLIDE 10/19
Afdeling Toegepaste Wiskunde / Division of Applied Mathematics
Image segmentation (10.2.5 to 10.2.6) SLIDE 11/19

The LoG filter is first convolved with the input image f (x, y),

g(x, y) = [∇2G(x, y)]⋆f (x, y) = ∇2[G(x, y)⋆f (x, y)]

after which the zero-crossings of g(x, y) is found

Summary of algorithm:
(1) Filter input image with n × n Gaussian lowpass filter (sample eqn (1))
(2) Compute the Laplacian of the result in step (1)
(3) Find the zero-crossings in the result in step (2)

• Rule of thumb: n ≡ smallest odd integer greater than or equal to 6σ


• A zero-crossing at p implies that the sign of at least two of its oposing
neibouring pixels must differ and that the absolute value of this difference
must exceed a certain threshold
Afdeling Toegepaste Wiskunde / Division of Applied Mathematics
Image segmentation (10.2.5 to 10.2.6) SLIDE 12/19

Example 10.7

• σ = 4 (≈ 0.5% of smallest image dimension) • DoG (READ)


Afdeling Toegepaste Wiskunde / Division of Applied Mathematics
Image segmentation (10.2.5 to 10.2.6) SLIDE 13/19

The Canny edge detector [1986] • Driven by 3 objectives:


(1) Low error rate: All edges should be found
(2) Edge points should be well localized: Edges found must be as close as
possible to true edges
(3) Single edge point response: Only one point for each true edge point
should be returned
Canny concluded that a good approximation to the optimal step edge de-
tector is the first derivative of a Gaussian
d − x22 x − x22
e 2σ = − 2 e 2σ
dx σ
For 2-D, the 1-D approach still applies in the direction of the edge normal
Since normal direction is unknown beforehand, 1-D detector has to be ap-
plied for all directions
This is approximated by (1) smoothing image with 2-D Gaussian; (2) com-
pute the gradient of the result; (3) use gradient magnitude and direction
to estimate edge strength and direction at every point
Afdeling Toegepaste Wiskunde / Division of Applied Mathematics
Image segmentation (10.2.5 to 10.2.6) SLIDE 14/19

Smoothed image fs is first formed by convolving G and f :


fs(x, y) = G(x, y)⋆f (x, y)

The gradient magnitude and direction are then calculated:



2 2 −1 gy
M(x, y) = gx + gy ; α(x, y) = tan
gx

Wide ridges are then thinned using nonmaxima supression:

• Specify number of discrete orientations of the edge normal (for a 3 × 3


region, we can specify four orientations: horizontal, vertical, +45◦, and −45◦)

• If edge normal is in range of directions from −22.5◦ to +22.5◦, or from


−157.5◦ to +157.5◦, the edge is deemed “horizontal”

• Let d1, d2, d3, and d4 denote the four basic edge directions: horizontal,
−45◦, vertical, and +45◦
Afdeling Toegepaste Wiskunde / Division of Applied Mathematics
Image segmentation (10.2.5 to 10.2.6) SLIDE 15/19
Afdeling Toegepaste Wiskunde / Division of Applied Mathematics
Image segmentation (10.2.5 to 10.2.6) SLIDE 16/19

Nonmaxima supression scheme for 3 × 3 region centered at every point (x, y)


in α(x, y):

(1) Find the direction dk that is closest to α(x, y)


(2) If the value of M(x, y) is less than at least one of its two neighbours
along dk , then gN (x, y) = 0 (supression); otherwise gN (x, y) = M (x, y)

Final operation is to threshold gN (x, y) to reduce false edge points


• Hysteresis thresholding (Section 10.3.6): Two thresholds, TL and TH are
selected using Otsu’s method

gNH(x, y) = (gN (x, y) ≥ TH ) gNL(x, y) = (gN (x, y) ≥ TL)


gNL(x, y) = gNL(x, y) − gNH(x, y)
gNH(x, y) ≡ “strong” edge pixels gNL(x, y) ≡ “weak” edge pixels

Strong pixels in gNH(x, y) are assumed to be valid and marked accordingly


Also, the edges in gNH(x, y) typically have gaps!
Afdeling Toegepaste Wiskunde / Division of Applied Mathematics
Image segmentation (10.2.5 to 10.2.6) SLIDE 17/19

Longer edges are formed using the following procedure:


(a) Locate the next unvisited pixel, p, in gNH(x, y)
(b) Mark as valid edge pixels all the weak pixels in gNL(x, y) that are con-
nected to p (8-connectivity)
(c) If all nonzero pixels in gNH(x, y) have been visited, go to step (d). Else,
return to step (a)
(d) Set to zero all pixels in gNL(x, y) that were not marked as valid edge pixels

Final output image is formed by appending to gNH(x, y) all the nonzeo pixels
from gNL(x, y)
Summary: (Step (4) is typically followed by one pass of edge thinning)
(1) Smooth the input image with a Gaussian filter
(2) Compute the gradient magnitude and angle images
(3) Apply nonmaxima supression to the gradient magnitude image
(4) Use double thresholding and connectivity analysis to detect and link
edges
Afdeling Toegepaste Wiskunde / Division of Applied Mathematics
Image segmentation (10.2.5 to 10.2.6) SLIDE 18/19
Afdeling Toegepaste Wiskunde / Division of Applied Mathematics
Image segmentation (10.2.5 to 10.2.6) SLIDE 19/19

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy