CMT107 Visual Computing
Edge Detection
Copyright By PowCoder代写 加微信 powcoder
Xianfang Sun,
School of Computer Science and Informatics
Cardiff University
• Origin of Edges
• Characterising Edges
• Derivatives with Convolution
• Finite Difference Filters
• Image Gradient
• Canny Edge Detector
Edge Detection
• Goal: identify sudden changes (discontinuities)
in an image
• Intuitively, most semantic and shape information
from the image can be encoded in the edges
• More compact than pixels
• Ideal: artist’s line drawing (but artists are also
using object-level knowledge)
Origin of Edges
• Edges are caused by a variety of factors
Surface normal discontinuity
Depth discontinuity
Surface colour discontinuity
Illumination discontinuity
Characterising Edges
• An edge is a place of rapid change in the image intensity function
intensity function
(along horizontal scanline) first derivative
edges correspond to
extrema of derivative
Derivatives with Convolution
• For 2D function 𝑓(𝑥, 𝑦), the partial derivative is:
𝑓 𝑥 + 𝜀, 𝑦 − 𝑓(𝑥, 𝑦)
• For discrete data, we can approximate using finite differences:
𝑓 𝑥 + 1, 𝑦 − 𝑓(𝑥, 𝑦)
• To implement the above as convolution, what would be the associated filter?
Partial Derivatives of an image
(or )
(or )
Intensity normalized to [0,255]
Can you tell which shows changes with respect to 𝑥?
Roberts: 𝑀𝑥 = , 𝑀𝑦 =
Finite Difference Filters
• Other approximations of derivative filters:
Prewitt: 𝑀𝑥 = , 𝑀𝑦 =
Sobel: 𝑀𝑥 = , 𝑀𝑦 =
Image Gradient
• The gradient of an image: ∇𝑓 = (
The gradient points in the direction of most rapid increase in intensity
• The gradient direction is given by 𝜃 = tan−1( ൗ
The gradient magnitude defines the edge strength: ∇𝑓 =
Effects of Noise
• Consider a single row or column of the image, and plot the intensity as a
function of position
Where is the edge?
• Solution: smooth first
Effects of Noise
To find edges, look for
• Differentiation is convolution, and convolution is associative:
𝑓 ∗ 𝑔 = 𝑓 ∗
Derivative Theorem of Convolution
This saves us one
• Which finds horizontal /
vertical edges?
• Are these filters separable?
Derivative of Gaussian filter
x direction y direction
• Smoothed derivative removes noise, but blurs edge. Also find edges at
different “scales”.
Scale of Gaussian Derivative Filter
3 pixels 7 pixels1 pixel
• Smoothing filters
• Gaussian: removes “high-frequency” components; “low-pass” filter
• Can the values of a smoothing filter be negative?
• What should the values sum to?
• One: constant regions are not affected by the filter
• Derivative filters
• Derivatives of Gaussian
• Can the values of a derivative filter be negative?
• What should the values sum to?
• Zero: no response in constant regions
• High absolute value at points of high contrast
Review: Smoothing vs. Derivative Filters
Canny Edge Detector
Original image
Canny Edge Detector
Norm of the gradient
Canny Edge Detector
Thresholding
How to turn these
thick regions of the
gradient into curves?
• Check if pixel is local maximum along gradient direction. Select single max
across width of the edge
• Requires checking interpolated pixels p and r
Non-maximum Suppression
Canny Edge Detector
(non-maximum suppression)
Problem: pixels
along this edge
didn’t survive the
thresholding
• Use a high threshold to start edge curves,
and a low threshold to continue them
Hysteresis Thresholding
Hysteresis Thresholding
high threshold
(strong edges)
low threshold
(weak edges)
hysteresis threshold
Original image
1. Filter image with derivative of Gaussian
2. Find magnitude and orientation of gradient
3. Non-maximum suppression:
• Thin wide “ridges” down to one pixel width
4. Linking and thresholding (hysteresis):
• Define two thresholds: low and high
• Use the high threshold to start edge curves and low threshold to continue
J. Canny, A Computational Approach To Edge Detection, IEEE Trans. Pattern Analysis and
Machine Intelligence, 8:679-714, 1986.
Summary of Canny Edge Detector
http://www.limsi.fr/Individu/vezien/PAPIERS_ACS/canny1986.pdf
• What is edge detection?
• Describe different origin of edges.
• How to characterise edges?
• How to calculate image gradient using Prewitt, Sobel, or Roberts filters?
• Describe the steps of Canny edge detector.
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com