CS4495/6495 Introduction to Computer Vision 2A-L5 Edge detection: - - PowerPoint PPT Presentation

cs4495 6495
SMART_READER_LITE
LIVE PREVIEW

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-1
SLIDE 1

2A-L5 Edge detection: Gradients

CS4495/6495 Introduction to Computer Vision

slide-2
SLIDE 2

Reduced images

slide-3
SLIDE 3

Reduced images

Edges seem to be important…

slide-4
SLIDE 4

Origin of Edges

depth discontinuity surface color discontinuity illumination discontinuity surface normal discontinuity

slide-5
SLIDE 5

In a real image

Depth discontinuity:

  • bject boundary

Discontinuous change in surface

  • rientation

Cast shadows Reflectance change: appearance information, texture

slide-6
SLIDE 6

Edge detection

slide-7
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
SLIDE 8

Recall images as functions…

Edges look like steep cliffs

slide-9
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
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
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
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
SLIDE 13

What’s a gradient?

slide-14
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
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
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
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
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
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
SLIDE 20

Finite differences

Source: D.A. Forsyth

slide-21
SLIDE 21

Finite differences – x or y?

Source: D. Forsyth

slide-22
SLIDE 22

Partial derivatives of an image

  • 1 1

( , ) f x y x   ( , ) f x y y  

(correlation filters)

slide-23
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
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
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
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
SLIDE 27
  • riginal image gradient thresholded

magnitude gradient magnitude

Sobel Operator on Blocks Image

slide-28
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
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
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
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
SLIDE 32

Finite differences responding to noise

Increasing noise (this is zero mean additive Gaussian noise)

Source: D. Forsyth

slide-33
SLIDE 33

Solution: smooth first

f

slide-34
SLIDE 34

Solution: smooth first

h

f

slide-35
SLIDE 35

Solution: smooth first

h f 

h

f

slide-36
SLIDE 36

Solution: smooth first

( )

x

h f

 

 h f 

h

f

slide-37
SLIDE 37

Where is the edge?

Solution: smooth first

( )

x

h f

 

 h f 

h

f

Look for peaks

slide-38
SLIDE 38

Derivative theorem of convolution

This saves us one operation:

( ) ( )

x x

h f h f

   

  

slide-39
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
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
SLIDE 41

Quiz

Which linearity property did we take advantage

  • f to first take the derivative of the kernel and

then apply that?

a) associative b) commutative c) differentiation d) (a) and (c)