You are on page 1of 15

General

Under rather general assumptions about the image formation


DD2422 Image Processing and Computer Vision the world consists of smooth regular surfaces with different
EDGE DETECTION reflectance properties.
One can assume that a discontinuity in image brightness
Danica Kragic corresponds to a discontinuity in (and their combinations):
Computational Vision and Active Perception
• depth,
School of Computer Science and Communication
• surface orientation,

February 11, 2008


• reflectance, or
• illumination.
Thus, find discontinuities in image brightness (edges) and char-
acterize these with respect to the physical phenomena that gave
rise to them.
DD2422 BILDAT DD2422 BILDAT

Edge detection applications


Example: Line drawing
• In computer vision:
- object recognition
- line drawing analysis
- motion algorithms
• In image analysis:
- segmentation
- enhancement
Note: An edge representation may correspond to substantial
data reduction
• Moreover: If a perfect line structure can be computed, sub-
sequent analysis will be simplified
DD2422 BILDAT DD2422 BILDAT
Example: Line drawing Example: Line drawing

Luminance and second order derivative. Noisy luminance and second order derivative.

DD2422 BILDAT DD2422 BILDAT

Why edges?
How do edges look in practice?

Ideal models:

Step edge Ramp edge Line Ridge

In practice, edges are blurred and noisy.

Problem: Concept of discontinuity doesn’t exist for discrete data!

DD2422 BILDAT DD2422 BILDAT


Fundamental problem

Differentiation is ill posed - an arbitrary small perturbation in the input can


lead to arbitrarily large perturbation in the output.
Ex: f (x) = arctan(x) f 0 (x) = 1 Noise reduction: Smoothing
1+x2

• Basic idea: Precede differentiation by smoothing.


• Trade-off problem:
- increasing amount of smoothing: stronger suppression of
f (x) = arctan(x) + ε sin ωx f 0 (x) = 1
1+x2 + εω cos ωx . noise, higher distortion of “true” structures.
- decreasing amount of smoothing: more accurate feature
detection, higher number of “false positives”

• The difference εω cos ωx can be arbitrarily large if ω >> 1/ε.


DD2422 BILDAT DD2422 BILDAT

Basic methods for edge detection

• Linear:
- Differentiation
- High-pass filtering
- Matching with model patterns
• Non-linear:
- Fitting of parameterized edge models
- Non-linear diffusion
• Common approach:
1. Detect edge points
2. Link these to polygons
3. Abstraction: Fit to model (straight lines, splines, ellipses )

DD2422 BILDAT DD2422 BILDAT


Method: gradients and derivatives
Edge attributes and problems

• Attributes:
- Position
- Orientation
- Strength
- Diffuseness (width)
• Problems: • Most methods are gradient based
- Noise • Detection of maxima of gradient
- Interference (nearby structures at different scales) • Detection of zero crossings of second derivative
- Physical interpretation • Edge pixels need to be connected together to get to a se-
quence of edge points (edge linking)
DD2422 BILDAT DD2422 BILDAT

The gradient

DD2422 BILDAT DD2422 BILDAT


Gradient

Question?

DD2422 BILDAT DD2422 BILDAT

Gradient
Gradient

DD2422 BILDAT DD2422 BILDAT


Gradient

DD2422 BILDAT DD2422 BILDAT

Magnitude
Basic edge detection

DD2422 BILDAT DD2422 BILDAT


In practice In practice
Edges are found by thresholding on the magnitude!

DD2422 BILDAT DD2422 BILDAT

Sobel operator, Cont.


Sobel operator

DD2422 BILDAT DD2422 BILDAT


Sobel operator and noise suppression Different filter types

DD2422 BILDAT DD2422 BILDAT

Zero crossings - Laplacian operator


Example: Roberts vs. Prewitt filter
Instead of the maxima of the gradient, we search the zero crossings of the
The principal edges are better detected.
second derivative.

DD2422 BILDAT DD2422 BILDAT


LoG and DoG Difference of Gaussians
The 2D LoG function centered on zero and with Gaussian stan-
dard deviation σ has the form:

The LoG operator can be very effectively approximated by con-


volution with a mask that is the difference of two Gaussian aver-
aging masks – this is called the Difference of Gaussians – DoG.

DD2422 BILDAT DD2422 BILDAT

The Laplacian operator - Properties Laplacian operator

• Advantages:
- Closer to mechanisms of visual perception
- One parameter only (size of the filter)
- No threshold
- Produces closed contours
• Disadvantages:
- Is more sensitive to noise (usage of second derivative)
- No information on the orientation of the contour
• Combination of gradient and contour:
- Search for zero-crossings of the Laplacian in the neighbor-
hood of local maxima of the gradient
DD2422 BILDAT DD2422 BILDAT
Zero crossings Detecting Edges by Matching

Idea: Match local image patches to set of edge models with


different orientation.
Direction: Orientation of best match (strongest response)
Edge strength: Strongest response
Example:
−1 1
  0 √2  1 1
  √2 0 
−1 1 , −√2 0 , −1 −1 , 0 √2

Natural measure: Normalized cross correlation


Cfg
C̃ f g = p p
C f f Cgg

DD2422 BILDAT DD2422 BILDAT

The Marr-Hildreth method Marr/Hildreth example

• Zero-crossings of ∇2(Gaussian)
• Motivation:
- Gaussian function best compromise between detection and
localization.
- Intensity change = Peak in 1st derivative =
Zero-crossing in 2nd derivative
- Rotational invariance ⇒ choose ∇2
• Detect zero-crossings in the result of convolving f by
x2 + y2 − 2t
∇2 g(x, y;t) = √ g(x, y;t) Marr/Hildreth edge detection is based on the zero-crossings of the Laplacian
t2 of the Gaussian operator applied to the image for various values of sigma, the
standard deviation of the Gaussian. Image shows a mosaic of zero-crossings
1 − x2 +y2
g(x, y;t) = e 2t for four choices of sigma:1, 2, 3 and 4.
2πt
DD2422 BILDAT DD2422 BILDAT
DD2422 BILDAT DD2422 BILDAT

Canny example

Gaussian smoothing

Zero-crossings in Marr/Hildreth edge detection always form connected, closed


contours. This comes at the expense of localization for larger values of sigma.
Canny edge detection does a better job of localization - with Canny edge de-
tection, the edge segments can become disconnected.
DD2422 BILDAT DD2422 BILDAT
Gradient Gradient orientation

DD2422 BILDAT DD2422 BILDAT

Gradient orientation

Non-maximum suppression

Implementation by discrete local search


1. Interpolate
- gradient magnitude, and
- gradient direction
2. Perform local search at each point
⇒ gives edge points that can be linked into polygons.

DD2422 BILDAT DD2422 BILDAT


Non-maximum suppression
Gradient orientation

DD2422 BILDAT DD2422 BILDAT

DD2422 BILDAT DD2422 BILDAT


Hysteresis thresholding
Hysteresis thresholding
- Motivation: Raw thresholding on gradient magnitude may result in highly
fragmented edges.

DD2422 BILDAT DD2422 BILDAT

Edge linking Differential geometric edge definition

Link neighboring edge pixels to connected contours. Non-maximum suppression:


Each point has strength | ∇L | and orientation Θ. • Edge point = point where the gradient magnitude assumes a
maximum in the gradient direction.
Algorithm: ∀ pixels
if (| ∇L |> threshold) This can be expressed in terms of
∀ neighbor’s Gradient: ∇L = (Lx , Ly )T , and
if (| ∇L | of neighbor > threshold) q
and ( | Θthis − Θneighbor |< threshold) Gradient magnitude: Lx2 + Ly2 .
link these pixels to be connected
Normalized gradient direction:
∇L (Lx , Ly )T
Combine with efficient traversal procedure and mechanism for n̄ = =q
| ∇L | L2 + L2
closing gaps. x y

DD2422 BILDAT DD2422 BILDAT


Gradient magnitude
Differential geometric edge definition
Requirements for gradient magnitude to be maximal in gradient direction:

Directional derivative in direction v̄ = (cos α, sin α): Ln̄n̄ = 0 Ln̄n̄n̄ ≤ 0

∂v̄ = cos α∂x + sin α∂y • In terms of coordinates:

Ln̄n̄ = (cos ∂x + sin ∂y )2 L = cos2 αLxx + 2 cos α sin αLxy + sin2 αLyy
Directional derivative in gradient direction: L2 2Lx Ly Ly2
= q x Lxx + q Lxy + q Lyy
Lx Ly Lx2 + Ly2 Lx2 + Ly2 Lx2 + Ly2
∂n̄ = q ∂x + q ∂y
Lx2 + Ly2 Lx2 + Ly2 (Lx2 Lxx + 2Lx Ly Lxy + Ly2 Lyy )
= q =0
Lx2 + Ly2
Denote:
• Since denominator is irrelevant, edges are given by
Lx Ly
∂n̄ L = Ln̄ = q Lx + q Ly Lx2 Lxx + 2Lx Ly Lxy + Ly2 Lyy = 0
Lx2 + Ly2 2 2
Lx + Ly
Lx3 Lxxx + 3Lx2 Ly Lxxy + 3Lx Ly2 Lxyy + Ly3 Lyyy ≤ 0

DD2422 BILDAT DD2422 BILDAT

Summary

Readings

• Related sections of Chapter 4, 5 and 10

DD2422 BILDAT DD2422 BILDAT

You might also like