Edge Detection

Download as pdf or txt
Download as pdf or txt
You are on page 1of 33

Introduction to Computer Vision

(ME-4201)

Edge detection
Phung Thanh Huy
Department of Mechatronics
Ho Chi Minh City University of Technology
Vietnam National University Ho Chi Minh City
Ver2024.1

Tp. Hồ Chí Minh – 2024


Edge and edge detection
Edges
• Sudden changes in an image’s intensity
• Edges usually appear at objects’ boundaries.
• From edges, we can take information about the objects.
• Edges could be used for segmentation, object detection…

Edge Detection|2
Edge and edge detection
Edges
• Sudden changes in an image’s intensity
• Edges usually appear at objects’ boundaries.
• From edges, we can take information about the objects.
• Edges could be used for segmentation, object detection…

Edge Detection|3
Edge and edge detection
Edges
• Results of different reasons Color,
Differences in Depth Illumination,
and Orientation Reflectance

Edge Detection|4
Edge and edge detection
Edges
• Results of different reasons

Edge Detection|5
Edge and edge detection
Edges
• Change of intensity

Edge Detection|6
Basic edge detectors
Derivatives – Gradient and Edges
Images and Edges

Caroline Rougier. Traitement d'images (IFT2730). Univ. de Montréal.


Edge Detection|7
Basic edge detectors
Laplacian Consider diag. also

Thresholding to detect isolated points and lines

Convoluted with Laplacian

Edge Detection|8
Basic edge detectors
Laplacian +45 deg -45 deg

Edge Detection|9
Basic edge detectors
Derivatives – Gradient and Edges
1-D Function Derivative

Descrete: Δ𝑥 = 1 𝑓𝑛′ = Δ × 𝑓𝑛
Δ
Forward

Backward

Central

Edge Detection|10
Basic edge detectors
Derivatives – Gradient and Edges
2-D function

Edge Detection|11
Basic edge detectors
Derivatives – Gradient and Edges
Extract Edges from derivatives

- Gradient x and y
Gradient kernels by 𝑥 and 𝑦
−1 1 −1 0 1

−1
−1 0
1 1
- Robert kernel (Robert cross): Gradient based on diag.

Edge Detection|12
Basic edge detectors
Derivatives – Gradient and Edges
Extract Edges from derivatives
- Prewitt Operator Sum of a row/ column.

- Sobel Operator Sum of a row/ column.

Edge Detection|13
Basic edge detectors
Noise and edges
Due to noise, the edges could be eliminated

Edge Detection|14
Basic edge detectors
Noise and edges
Filtering and detecting edges

Edge Detection|15
Basic edge detectors
Noise and edges
Filtering and detecting edges

Edge Detection|16
Basic edge detectors
Noise and edges
Filtering and detecting edges
Sobel Operator

Prewitt Operator

Edge Detection|17
Basic edge detectors
Noise and edges Sobel 𝑔𝑥 , 𝑔𝑦 , 𝑔𝑥 + 𝑔𝑦

Edge Detection|18
Basic edge detectors
Sobel’s problems Sobel 𝑔𝑥 , 𝑔𝑦 , 𝑔𝑥 + 𝑔𝑦

• Poor Localization (Trigger response in multiple adjacent pixels)


• Thresholding value favors certain directions over others
• Can miss oblique edges more than horizontal or vertical edges
• False negatives

Edge Detection|19
Basic edge detectors
Noise and edges

Edge Detection|20
Basic edge detectors
Direction

Edge Detection|21
Advanced edge detectors
Marr-Hildreth Edge Detector – LoG (Laplacian of Gaussian)
Basics
- Intensity changes are not independent of image scale. Determination of
edges needs operators of different sizes
- Changes of intensity causes peaks (1st deviation) or zero-crossing (2nd
deviation)

Features of Marr-Hildreth Edge detection


- Differential operator
- Can be used with different scale

∇2 𝐺 : Laplacian of Gaussian (LoG)

Space constant

Edge Detection|22
Advanced edge detectors
Marr-Hildreth Edge Detector – LoG (Laplacian of Gaussian)

Mexican hat operator

Edge Detection|23
Advanced edge detectors
Marr-Hildreth Edge Detector – LoG (Laplacian of Gaussian)

𝐿𝑜𝐺 could be estimated with DoG, difference of Gaussians (DoG):

𝜎12 𝜎22 𝜎12


Equivalent 𝜎2 = ln
𝜎12 −𝜎22 𝜎22

Gaussian 1 - Gaussian 2

Edge Detection|24
Advanced edge detectors
Marr-Hildreth Edge Detector – LoG (Laplacian of Gaussian)
Zero crossing

Edge Detection|25
Advanced edge detectors
Canny Edge Detector
• The Canny operator maps a scalar image into a binary edge map of “thin”
(i.e. having the width of one pixel only) edge segments.
• The output is not uniquely defined; it depends on two thresholds Tlow and
Thigh with 0 < Tlow < Thigh < Gmax, not counting a fixed scale used for
Gaussian smoothing.
• Criteria for an “optimal” edge detector [Canny 1986]:
• Good detection: the optimal detector must minimize the probability
of false positives (detecting spurious edges caused by noise), as well
as that of false negatives (missing real edges).
• Good localization: the edges detected must be as close as possible
to the true edges.
• Single response: the detector must return one point only for each
true edge point; that is, minimize the number of local maxima around
the true edge.

Edge Detection|26
Advanced edge detectors
Canny Edge Detector

1. Filter the image with the Derivative of Gaussian.


2. Find the magnitude and orientation of the gradient.
3. Non-maximum suppression: Thin multi-pixel wide “ridges” down to single-pixel
width.
4. Linking and thresholding (hysteresis):
Define two thresholds: low and high
Use the high threshold to start edge curves and the low threshold to continue
them.

Edge Detection|27
Advanced edge detectors
Canny Edge Detector
Direction of each pixel

Edge Detection|28
Advanced edge detectors
Canny Edge Detector
Magintude

Edge Detection|29
Advanced edge detectors
Canny Edge Detector
1. Smooth the image with Gaussian Filter

2. Compute the gradient magnitude and angle images.


Magnitude Direction

X-Derivative of Y-Derivative of Gradient Magnitude


Gaussian Gaussian
Edge Detection|30
Advanced edge detectors
Canny Edge Detector
3. Apply nonmaxima suppression to the gradient magnitude image

Edge Detection|31
Advanced edge detectors
Canny Edge Detector
Non-maximum suppression

At q, we have a
maximum if the
value is larger
than those at
both p and at r.
Interpolate to get
these values.

Source: D. Forsyth

Edge Detection|32
Advanced edge detectors
Canny Edge Detector
4. Use double thresholding and connectivity analysis to detect and link edges.

strong edge pixel weak but connected


edge pixels

strong edge pixel

Source: S. Seitz

Edge Detection|33

You might also like