0% found this document useful (0 votes)
13 views39 pages

2.4 - EdgeDetecting

The document discusses various techniques for edge detection in image processing, focusing on point detection, line detection, and the Laplacian of Gaussian (LoG) method. It outlines the Marr-Hildreth algorithm and the Canny edge detection algorithm, detailing the steps involved in each process. Additionally, it highlights the properties of edges, the impact of noise on detection, and the importance of thresholding in identifying edges.

Uploaded by

baotran.fablab
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)
13 views39 pages

2.4 - EdgeDetecting

The document discusses various techniques for edge detection in image processing, focusing on point detection, line detection, and the Laplacian of Gaussian (LoG) method. It outlines the Marr-Hildreth algorithm and the Canny edge detection algorithm, detailing the steps involved in each process. Additionally, it highlights the properties of edges, the impact of noise on detection, and the importance of thresholding in identifying edges.

Uploaded by

baotran.fablab
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/ 39

Edge Detection

LE Thanh Sach

Chapter 3.3
Point Detection
Edge Detection Line Detection

Edge Detection
Image Processing and Computer Vision Laplacian of
Gaussian (LoG)

LE Thanh Sach
Faculty of Computer Science and Engineering
Ho Chi Minh University of Technology, VNU-HCM

3.3.1
Edge Detection
Overview
LE Thanh Sach

1 Point Detection
Point Detection

Line Detection
2 Line Detection Edge Detection

Laplacian of
Gaussian (LoG)

3 Edge Detection

4 Laplacian of Gaussian (LoG)

3.3.2
Edge Detection
Point Detection
LE Thanh Sach

1 Filter the input image f (x, y) with Laplacian Hlap , i.e.,


compute g(x, y) = f (x, y) ∗ Hlap (i, j)
Point Detection
2 Detect isolated points (x, y) if they satisfy: Line Detection
|g(x, y)| ≥ T . Where, T is a threshold value. Edge Detection

Laplacian of
Laplacian kernel Hlap : Gaussian (LoG)

 
−1 −1 −1
Hlap =  −1 8 −1 
−1 −1 −1

3.3.3
Edge Detection
Line Detection
LE Thanh Sach

1 Filter the input image f (x, y) with all following masks


for detecting horizontal, vertical, ±450 -oriented lines.
This process results gi (x, y), i = 1..4. You can design
new masks for other lines with new orientation.
Point Detection
2 Chose a orientation i for point (x, y) by selecting the
Line Detection
largest gi (x, y), i = 1..4.
Edge Detection
3 Do thresholding with a certain T (input) to obtain lines. Laplacian of
Gaussian (LoG)
Some kernels:
   
−1 −1 −1 −1 2 −1
 2 2 2   −1 2 −1 
−1 −1 −1 −1 2 −1
Horizontal Vertical
   
−1 −1 2 2 −1 −1
 −1 2 −1   −1 2 −1 
2 −1 −1 −1 −1 2
+450 −45 0
3.3.4
Edge Detection
Edge Detection
LE Thanh Sach

Definition
Edge is a set of connected pixels that lie on the boundary Point Detection

between two regions. Line Detection

Edge Detection

Laplacian of
Properties Gaussian (LoG)

1 There is ”meaningful” transitions in gray-levels at edge.


2 So, first-order and second-order derivatives can be used
to detect the transition.

3.3.5
Edge Detection
Edge Detection
LE Thanh Sach
Examples of Derivatives: image, a line profile, first and
second-order derivatives.

Point Detection

Line Detection

Edge Detection

Laplacian of
Gaussian (LoG)

3.3.6
Edge Detection
Edge Detection
LE Thanh Sach

Model of edges:

Point Detection

Line Detection

Edge Detection

Laplacian of
Gaussian (LoG)

1 Left: Clear edge or Ideal edge, ideally represented as


a step
2 Middle: Blurred edge, ideally represented as a ramp
3 Right: A blurred bright edge, ideally represented as a
roof.

3.3.7
Edge Detection
Edge Detection
LE Thanh Sach

Point Detection

Line Detection

Edge Detection

Laplacian of
Gaussian (LoG)

Edge with first-order derivatives


Edge consists of points where the module of the gradient
vector is greater than a threshold.
• The gradient vector is perpendicular with the local
edge passing that point
3.3.8
Edge Detection
Edge Detection
LE Thanh Sach

Point Detection

Line Detection

Edge Detection

Laplacian of
Gaussian (LoG)

Edge with second-order derivatives


Edge consists of zero-crossing points in image filtered with
second-order derivatives.
• Second-order derivatives create one positive response
and another negative one for ramp edges.
3.3.9
Edge Detection
Edge Detection with noise
LE Thanh Sach

Point Detection

Line Detection

Edge Detection

Laplacian of
Gaussian (LoG)

• Rows: Row 1: no noise; Row 2: with Gaussian noise


(µ = 0, σ = 0)
• Cols: Col 1: a line profile; Col 2: Fist-order derivative;
Col 3: Second-order derivative
3.3.10
Edge Detection
Edge Detection with noise
LE Thanh Sach

Point Detection

Line Detection

Edge Detection

Laplacian of
Gaussian (LoG)

• Rows: Row 1: with Gaussian noise (µ = 0, σ = 0.1);


Row 2: with Gaussian noise (µ = 0, σ = 1.0)
• Cols: Col 1: a line profile; Col 2: Fist-order derivative;
Col 3: Second-order derivative
3.3.11
Edge Detection
Edge Detection with noise
LE Thanh Sach

Properties
Point Detection

Line Detection
• Second-order derivative is more sensitive to noise Edge Detection
compared with first-order derivative. Laplacian of
Gaussian (LoG)
• However,
• First-order derivatives provide thick edges
• Second-order derivatives provide thin edges (via,
zero-crossing)

3.3.12
Edge Detection
Edge Detection and Laplacian
LE Thanh Sach

Question
Laplacian can provide the discontinuity in gray-levels. Why
is it not used in edge detection?
Point Detection

Line Detection
Reasons
Edge Detection

1 As a second-order derivative, it is unacceptably sensitive Laplacian of


Gaussian (LoG)
to noise
2 The magnitude of Laplacian provides double edges (one
for positive and another one for negative response)
3 Laplacian can not provide edge direction

Therefore, Laplacian is directly suitable for sharpening


images only.

3.3.13
Edge Detection
Edge Detection and Laplacian
LE Thanh Sach

• Laplacian can provide thin edges via zeros-crossing


detection. However, it is sensitive to noise.
• What will be happened if we remove noise before taking
Laplician and then finding zeros-crossing?
Point Detection

Line Detection
Laplacian in edge detection
Edge Detection

Laplacian of
1 Perform noise removal will a Gaussian low-pass filter. Gaussian (LoG)
The input image will be blurred.
2 Apply Laplacian to the resulting image.
3 Detect zero-crossing points to obtain edge points.

Laplacian of Gaussian (LoG)


Step 1 and 2 in the above algorithm is equivalent to
filtering image with a LoG mask
3.3.14
Edge Detection
Laplacian of Gaussian (LoG)
LE Thanh Sach

A Gaussian function G(x, y)


Point Detection

Line Detection
2 +y 2
−x Edge Detection
G(x, y) = e 2σ 2
Laplacian of
Gaussian (LoG)

• σ : standard deviation. This parameter decides the


degree of blurring in output image, if the input
image is convoluted with this function

3.3.15
Edge Detection
Laplacian of Gaussian (LoG)
LE Thanh Sach

Laplacian of Gaussian (LoG)


Point Detection

Line Detection
r2 Edge Detection
x2 y2 2σ 2
 
+ − −
∇2 G(r) = e 2σ 2 Laplacian of
σ4 Gaussian (LoG)

• LoG ≡ Laplacian of function G(x, y)


2 2
• LoG ≡ ∂ G(x,y)
∂x2
+ ∂ G(x,y)
∂y 2

3.3.16
Edge Detection
Laplacian of Gaussian (LoG)
LE Thanh Sach

Point Detection

Line Detection

Edge Detection

Laplacian of
Gaussian (LoG)

3.3.17
Edge Detection
Laplacian of Gaussian (LoG)
LE Thanh Sach

Properties

1 Other name: Mexican hat, because of its shape


Point Detection
2 Zero-crossing point in LoG: x2 + y 2 = 2σ 2 Line Detection

3 Radius from the origin to zero-crossing point: r = 2σ Edge Detection

Laplacian of
4 Kernel of LoG given above: just an example. It can be Gaussian (LoG)

approximated by any size and any coefficients.


5 Sum of all coefficients of the kernel must be 0

Generation of LoG’s kernel


How can you generate LoG’s kernel?

3.3.18
Edge Detection
Laplacian of Gaussian (LoG)
LE Thanh Sach

Properties: Linearity Point Detection

Line Detection

Edge Detection
 2
 Laplacian of
g(x, y) = ∇ G(x, y) ∗ f (x, y) Gaussian (LoG)

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

3.3.19
Edge Detection
Marr-Hildreth Algorithm
LE Thanh Sach

Marr-Hildreth Algorithm

1 Filter the input image f (x, y) with Gaussian low-pass Point Detection

filter by kernel size n × n to obtain the output g(x, y). Line Detection

Edge Detection
2 Compute Laplacian of g(x, y) to obtain gL (x, y)
Laplacian of
3 Find zero-crossing points in gL (x, y) Gaussian (LoG)

LoG
Step 1 and 2 can be implemented as applying LoG on the
input image.

3.3.20
Edge Detection
Marr-Hildreth Algorithm
LE Thanh Sach

Power of Marr-Hildreth Algorithm


Marr-Hildreth Algorithm can remedy the following problems
in edge detection: Point Detection
1 Intensity changes are not independent of image scale ⇒ Line Detection

use different kernel’ size. Edge Detection

Laplacian of
2 Edges are sensitive to noise, especially true for Gaussian (LoG)
second-order derivative ⇒ use Gaussian low-pass filter

Questions

1 How can you obtain the kernel’s size?


2 How can you detect zero-crossing points?

3.3.21
Edge Detection
Marr-Hildreth Algorithm
LE Thanh Sach

Point Detection
How can you obtain the kernel’s size?
Line Detection

Edge Detection
• Volume of a Gaussian function inside of circle
Laplacian of
radius = 3σ is 99.7% Gaussian (LoG)

• ⇒ Kernel size n × n, where n an odd numer ≥ 6σ

3.3.22
Edge Detection
Marr-Hildreth Algorithm
LE Thanh Sach

How can you detect zero-crossing points?

1 Perform thresholding of the magnitude of LoG image,


i.e. |gl (x, y)|,
 with a value T .
−1 if (gl (x, y) < 0) and |gl (x, y)| > T
 Point Detection

gl (x, y) = 1 if (gl (x, y) > 0) and |gl (x, y)| > T Line Detection

Edge Detection

0 ortherwise

Laplacian of
Gaussian (LoG)
2 Apply a mask 3 × 3 at each pixel on gl (x, y).
NW N NE
W C E
SW S SE
3 Detect the difference on the sign at opposing corners,
i.e., (W, E), (N, S), (NW, SE), and (SW, NE).
4 If any pair of corners results a difference on the sign,
then gl (x, y) is an edge point.

3.3.23
Edge Detection
Laplacian of Gaussian (LoG): Illustration
LE Thanh Sach

Point Detection

Line Detection

Edge Detection

Laplacian of
Gaussian (LoG)

Figure: Original image


3.3.24
Edge Detection
Laplacian of Gaussian (LoG): Illustration
LE Thanh Sach

Point Detection

Line Detection

Edge Detection

Laplacian of
Gaussian (LoG)

Figure: Original image


3.3.25
Edge Detection
Laplacian of Gaussian (LoG): Illustration
LE Thanh Sach

Point Detection

Line Detection

Edge Detection

Laplacian of
Gaussian (LoG)

(a) (b)
Figure: Marr-Hildreth Algorithm: (a): Result of Step 1 and 2,
(b): Zero-crossing of (a), Threshold = 0

• Step 1 and 2: σ = 4, n = 25 (kernel’s size: 25 × 25)


• Low threshold ⇒ many edge points.
3.3.26
Edge Detection
Laplacian of Gaussian (LoG): Illustration
LE Thanh Sach

Point Detection

Line Detection

Edge Detection

Laplacian of
Gaussian (LoG)

(a) (b)
Figure: Marr-Hildreth Algorithm: (a): Result of Step 1 and 2, (b):
Zero-crossing of (a), Threshold = 4% of maximum value in (a)

• Step 1 and 2: σ = 4, n = 25 (kernel’s size: 25 × 25)


• Larger threshold ⇒ provide strong edge only
3.3.27
Edge Detection
Canny Edge Detection
LE Thanh Sach

Canny Edge Detection Algorithm


Point Detection

1 Smooth the input image with Gaussian low-pass filter Line Detection

2 Compute the gradient magnitude angle images Edge Detection

Laplacian of
3 Apply nonmaxima suppression to the gradient Gaussian (LoG)

magnitude image.
4 Use double thresholding and connectivity analysis to
detect and link edges

3.3.28
Edge Detection
Canny Edge Detection
LE Thanh Sach

Step 1: Smooth the input image with Gaussian low-pass


filter
Point Detection
1 Smooth the input image with Gaussian low-pass filter Line Detection

2 Compute the gradient magnitude angle images Edge Detection

Laplacian of
3 Apply nonmaxima suppression to the gradient Gaussian (LoG)

magnitude image.
4 Use double thresholding to obtain strong and weak edge
masks
5 Analyze the connectivity to detect and link edges

3.3.29
Edge Detection
Canny Edge Detection
LE Thanh Sach

Step 1: Smooth the input image with Gaussian low-pass


filter
Point Detection

Line Detection
2 2 Edge Detection
− x +y
G(x, y) = e 2σ 2
Laplacian of
Gaussian (LoG)
fs (x, y) = f (x, y) ∗ G(x, y)

• fs (x, y) : a smoothed version of f (x, y)


• σ : decides the degree of smoothing
• fs (x, y) : Gaussian noise has been removed

3.3.30
Edge Detection
Canny Edge Detection
LE Thanh Sach

Step 2: Compute the gradient magnitude angle images

• Compute gx (x, y) and gy (x, y)

gx (x, y) = fs (x, y) ∗ Hx (x, y) Point Detection

Line Detection
gy (x, y) = fs (x, y) ∗ Hy (x, y) Edge Detection

Laplacian of
Gaussian (LoG)
• Hx (x, y), Hy (x, y): any first-order derivative kernels,
e.g., ”standard” approximations kernels, Sobel, Roberts,
Prewitts, etc.
• Compute gradient magnitude and angle images
 
gx (x, y)
M (x, y) =
gy (x, y)
 
−1 gy (x, y)
α(x, y) = tan
gx (x, y)
3.3.31
Edge Detection
Canny Edge Detection
LE Thanh Sach

Step 3: Apply nonmaxima suppression to the gradient


magnitude image.
Point Detection

The underlying idea of nonmaxima suprression Line Detection

Edge Detection
if a point is not a local maxima, then supress (remove, stop,
Laplacian of
etc) it. Gaussian (LoG)

• Edges will pass points that are local maxima in


gradient magnitude image, ie., M (x, y).
• ⇒ Remove (supress) points that are not local maxima.
• ≡ nonmaxima suprression

3.3.32
Edge Detection
Canny Edge Detection
LE Thanh Sach

Step 3: Apply nonmaxima suppression to the gradient


magnitude image.

Questions Point Detection

What does local mean? Line Detection

Edge Detection

• local ≡ local points involving in edge. Laplacian of


Gaussian (LoG)

• for a point (x, y) in M (x, y), which neighbor points


are edge local points?
• ⇒ need gradient angle

Gradient vector at a point is perpendicular to local edge at


that point.

3.3.33
Edge Detection
Canny Edge Detection
LE Thanh Sach

Step 3: Apply nonmaxima suppression to the gradient


magnitude image.
Point Detection

1 Discrete gradient angle values into small rangles. Line Detection

Edge Detection
2 Find direction dk that is closest to α(x, y)
Laplacian of
3 Find local neighbors on edge using dk , referred to as N1 Gaussian (LoG)

and N2
4 Compute nonmaxima suppressed image gN (x, y)
(
0 if [M (x, y) < N1 ] & [M (x, y) < N2 ]
gN (x, y) =
M (x, y) otherwise

3.3.34
Edge Detection
Canny Edge Detection
LE Thanh Sach
Step 3: Apply nonmaxima suppression to the gradient
magnitude image.

Point Detection

Line Detection

Edge Detection

Laplacian of
Gaussian (LoG)

Figure: Demonstration for 4 directions: horizontal, vertical, ±450


3.3.35
Edge Detection
Canny Edge Detection
LE Thanh Sach

Step 4: Use double thresholding to obtain strong and weak


edge masks

1 Do thresholding with high and low threshold value TH


Point Detection
and TL respectively.
Line Detection

Edge Detection
gN H (x, y) = gN (x, y) ≥ TH
Laplacian of
gN L (x, y) = gN (x, y) ≥ TL Gaussian (LoG)

2 Eliminate points in gN L (x, y) that has been indicated in


gN H(x,y)

gN L (x, y) = gN L (x, y) − gN H (x, y)

• gN H (x, y): strong edge


• gN L (x, y): weak edge

3.3.36
Edge Detection
Canny Edge Detection
LE Thanh Sach

Step 5: Analyze connectivity and to detect and link edges

1 Create an edge map that marks all non-zeros in


Point Detection
gN H (x, y) as valid edge points.
Line Detection
2 For each pixel p that is non-zeros in gN H (x, y), do
Edge Detection
• Find all non-zeros pixels in gN L (x, y) that are
Laplacian of
connected to p via 4− or 8−connectivity, mark Gaussian (LoG)
corresponding points in edge map as valid pixels.

• edge map may contain edges thicker than 1 pixel.


• Apply edge-thinning algorithm to create thinner edge
map, if needed.

3.3.37
Edge Detection
Canny Edge Detection: Illustration
LE Thanh Sach

Point Detection

Line Detection

Edge Detection

Laplacian of
Gaussian (LoG)

(a) (b)
Figure: Edge detection (a): Original image, (b): Thresholded
gradient magnitude image - thick edge

3.3.38
Edge Detection
Canny Edge Detection: Illustration
LE Thanh Sach

Point Detection

Line Detection

Edge Detection

Laplacian of
Gaussian (LoG)

(a) (b)
Figure: Edge detection (a): Marr-Hildreth Method, (b): Canny
method - better

3.3.39

You might also like