SLIDE 1
CS4495/6495 Introduction to Computer Vision 2A-L5 Edge detection: - - PowerPoint PPT Presentation
CS4495/6495 Introduction to Computer Vision 2A-L5 Edge detection: - - PowerPoint PPT Presentation
CS4495/6495 Introduction to Computer Vision 2A-L5 Edge detection: Gradients Reduced images Reduced images Edges seem to be important Origin of Edges surface normal discontinuity depth discontinuity surface color discontinuity
SLIDE 2
SLIDE 3
Reduced images
Edges seem to be important…
SLIDE 4
Origin of Edges
depth discontinuity surface color discontinuity illumination discontinuity surface normal discontinuity
SLIDE 5
In a real image
Depth discontinuity:
- bject boundary
Discontinuous change in surface
- rientation
Cast shadows Reflectance change: appearance information, texture
SLIDE 6
Edge detection
SLIDE 7
Quiz
Edges seem to occur “change boundaries” that are related to shape or illumination. Which is not such a boundary?
a) An occlusion between two people b) A cast shadow on the sidewalk c) A crease in paper d) A stripe on a sign
SLIDE 8
Recall images as functions…
Edges look like steep cliffs
SLIDE 9
Edge Detection
Basic idea: look for a neighborhood with strong signs of change.
81 82 26 24 82 33 25 25 81 82 26 24
Problems:
- neighborhood size
- how to detect change
SLIDE 10
image
Derivatives and edges
intensity function
(along horizontal scanline)
An edge is a place of rapid change in the image intensity function.
Source: S. Lazebnik
SLIDE 11
Derivatives and edges
first derivative edges correspond to extrema of derivative
Source: S. Lazebnik
An edge is a place of rapid change in the image intensity function.
image intensity function
(along horizontal scanline)
SLIDE 12
Differential Operators
- Differential operators –when applied to the image
returns some derivatives.
- Model these “operators” as masks/kernels that
compute the image gradient function.
- Threshold the this gradient function to select the
edge pixels.
- Which brings us to the question:
SLIDE 13
What’s a gradient?
SLIDE 14
Image gradient
The gradient of an image: The gradient points in the direction of most rapid increase in intensity
[ , 0 ] f f x [0, ] f f y
[ , ] f f f x y
[ , ] f f f x y
SLIDE 15
Image gradient
The gradient of an image: The gradient direction is given by: The edge strength is given by the gradient magnitude:
[ , ] f f f x y
1
tan ( / ) f f y x
2 2
( ) ( ) f f f x y
SLIDE 16
Quiz
What does it mean when the magnitude of the image gradient is zero?
a) The image is constant over the entire
neighborhood.
b) The underlying function f(x,y) is at a maximum. c) The underlying function f(x,y) is at a minimum. d) Either (a), (b), or (c).
SLIDE 17
words
- So that’s fine for calculus and other
mathematics classes which you may now wish you had paid more attention. How do we compute these things on a computer with actual images.
- To do this we need to talk about discrete
gradients.
SLIDE 18
Discrete gradient
For 2D function, f(x,y), the partial derivative is:
( , ) ( , ) ( , ) lim f x y f x y f x y x
SLIDE 19
Discrete gradient
For discrete data, we can approximate using finite differences:
( , ) ( 1, ) ( , ) 1 f x y f x y f x y x ( 1, ) ( , ) f x y f x y
“right derivative” But is it???
SLIDE 20
Finite differences
Source: D.A. Forsyth
SLIDE 21
Finite differences – x or y?
Source: D. Forsyth
SLIDE 22
Partial derivatives of an image
- 1 1
( , ) f x y x ( , ) f x y y
(correlation filters)
SLIDE 23
Partial derivatives of an image
- 1
1 1
- 1
- r
?
- 1 1
( , ) f x y x ( , ) f x y y
(correlation filters)
SLIDE 24
The discrete gradient
- We want an “operator” (mask/kernel) that we
can apply to the image that implements:
How would you implement this as a cross-correlation? ( , ) ( , ) ( , ) lim f x y f x y f x y x
SLIDE 25
The discrete gradient
- 1/2 0 +1/2
- 1
+1
Not symmetric around image point; which is “middle” pixel? Average of “left” and “right” derivative . See?
H
H
SLIDE 26
g = (gx
2 + gy 2)1/2 is the gradient magnitude.
= atan2(gy , gx) is the gradient direction. (Sobel) Gradient is I = [gx gy]T
- 1 0 1
- 2 0 2
- 1 0 1
1 2 1 0 0 0
- 1 -2 -1
Example: Sobel operator
1 8 ∗ 1 8 ∗
𝑡𝑦 𝑡𝑧 (here positive y is up)
SLIDE 27
- riginal image gradient thresholded
magnitude gradient magnitude
Sobel Operator on Blocks Image
SLIDE 28
Some Well-Known Gradients Masks
- Sobel:
- Prewitt:
- Roberts:
Sx Sy
- 1
1
- 2
2
- 1
1 1 2 1
- 1 -2 -1
- 1
1
- 1
1
- 1
1 1 1 1
- 1 -1 -1
1
- 1
1
- 1
SLIDE 29
Matlab does gradients
filt = fspecial('sobel') filt = 1 2 1 0 0 0
- 1 -2 -1
- utim = imfilter(double(im),filt);
imagesc(outim); colormap gray;
SLIDE 30
Quiz
It is better to compute gradients using:
a) Convolution since that’s the right way to model
filtering so you don’t get flipped results.
b) Correlation because it’s easier to know which
way the derivatives are being computed.
c) Doesn’t matter. d) Neither since I can just write a for-loop to
computer the derivatives.
SLIDE 31
But in the real world…
Consider a single row or column of the image (plotting intensity as a function of x) Apply derivative operator…. Uh, where’s the edge?
( ) f x
( ) d f x d x
SLIDE 32
Finite differences responding to noise
Increasing noise (this is zero mean additive Gaussian noise)
Source: D. Forsyth
SLIDE 33
Solution: smooth first
f
SLIDE 34
Solution: smooth first
h
f
SLIDE 35
Solution: smooth first
h f
h
f
SLIDE 36
Solution: smooth first
( )
x
h f
h f
h
f
SLIDE 37
Where is the edge?
Solution: smooth first
( )
x
h f
h f
h
f
Look for peaks
SLIDE 38
Derivative theorem of convolution
This saves us one operation:
( ) ( )
x x
h f h f
SLIDE 39
Derivative theorem of convolution
f
h
x h
( )
x h
f
This saves us one operation:
( ) ( )
x x
h f h f
SLIDE 40
2nd derivative of Gaussian
Consider
Second derivative of Gaussian operator
Where is the edge?
2 2 (
)
x
h f
2 2 x
h
2 ( 2
)
x
h f
f
x h
SLIDE 41
Quiz
Which linearity property did we take advantage
- f to first take the derivative of the kernel and