Image Gradients and Gradient Filtering 16-385 Computer Vision What - - PowerPoint PPT Presentation

image gradients and gradient filtering
SMART_READER_LITE
LIVE PREVIEW

Image Gradients and Gradient Filtering 16-385 Computer Vision What - - PowerPoint PPT Presentation

Image Gradients and Gradient Filtering 16-385 Computer Vision What is an image edge? Recall that an image is a 2D function f ( x ) edge edge How would you detect an edge? What kinds of filter would you use? The Sobel filter 1 0 -1


slide-1
SLIDE 1

Image Gradients and Gradient Filtering

16-385 Computer Vision

slide-2
SLIDE 2

What is an image edge?

slide-3
SLIDE 3

f(x)

Recall that an image is a 2D function

slide-4
SLIDE 4

edge edge

How would you detect an edge? What kinds of filter would you use?

slide-5
SLIDE 5

The ‘Sobel’ filter

1

  • 1

2

  • 2

1

  • 1

a derivative filter (with some smoothing) Filter returns large response on vertical or horizontal lines?

slide-6
SLIDE 6

The ‘Sobel’ filter

1 2 1

  • 1
  • 2
  • 1

Filter returns large response on vertical or horizontal lines? Is the output always positive? a derivative filter (with some smoothing)

slide-7
SLIDE 7

The ‘Sobel’ filter

1 2 1

  • 1
  • 2
  • 1

Responds to horizontal lines Output can be positive or negative a derivative filter (with some smoothing)

slide-8
SLIDE 8

Output of which Sobel filter? Output of which Sobel filter? How do you visualize negative derivatives/gradients?

slide-9
SLIDE 9

Derivative in X direction Visualize with scaled absolute value Derivative in Y direction

slide-10
SLIDE 10

The ‘Sobel’ filter

1

  • 1

2

  • 2

1

  • 1

Where does this filter come?

slide-11
SLIDE 11

Do you remember this from high school?

f 0(x) = lim

h!0

f(x + h) − f(x) h

slide-12
SLIDE 12

Do you remember this from high school?

f 0(x) = lim

h!0

f(x + h) − f(x) h

The derivative of a function f at a point x is defined by the limit

Approximation of the derivative when h is small This definition is based on the ‘forward difference’ but ...

slide-13
SLIDE 13

f 0(x) = lim

h!0

f(x + 0.5h) − f(x − 0.5h) h it turns out that using the ‘central difference’ is more accurate How do we compute the derivative of a discrete signal?

10 20 10 200 210 250 250

slide-14
SLIDE 14

f 0(x) = lim

h!0

f(x + 0.5h) − f(x − 0.5h) h

How do we compute the derivative of a discrete signal?

10 20 10 200 210 250 250

f 0(x) = f(x + 1) − f(x − 1) 2 = 210 − 10 2 = 100

  • 1

1 1D derivative filter

it turns out that using the ‘central difference’ is more accurate

slide-15
SLIDE 15

1

  • 1

2

  • 2

1

  • 1

1

  • 1

=

1 2 1 What this? Sobel

Decomposing the Sobel filter

slide-16
SLIDE 16

1

  • 1

2

  • 2

1

  • 1

1

  • 1

=

1 2 1 weighted average and scaling Sobel

Decomposing the Sobel filter

slide-17
SLIDE 17

1

  • 1

2

  • 2

1

  • 1

1

  • 1

=

1 2 1 weighted average and scaling Sobel What this?

Decomposing the Sobel filter

slide-18
SLIDE 18

1

  • 1

2

  • 2

1

  • 1

1

  • 1

=

1 2 1 weighted average and scaling Sobel What this? x-derivative

Decomposing the Sobel filter

slide-19
SLIDE 19

The Sobel filter only returns the x and y edge responses. How can you compute the image gradient?

slide-20
SLIDE 20

1

  • 1

2

  • 2

1

  • 1

1 2 1

  • 1
  • 2
  • 1

How do you compute the image gradient?

Choose a derivative filter Run filter over image Image gradient What are the dimensions? What are the dimensions? What is this filter called?

∂f ∂x = Sx ⊗ f ∂f ∂y = Sy ⊗ f Sy = Sx = rf = ∂f ∂x , ∂f ∂y

slide-21
SLIDE 21

rf = ∂f ∂x, 0

  • rf =

 0, ∂f ∂y

  • rf =

∂f ∂x, ∂f ∂y

  • (a)

(b) (c) (1) (2) (3) Matching that Gradient !

slide-22
SLIDE 22

Image Gradient

rf = ∂f ∂x, 0

  • rf =

 0, ∂f ∂y

  • rf =

∂f ∂x, ∂f ∂y

  • Gradient in y only

Gradient in x only Gradient in both x and y

Gradient direction Gradient magnitude

? ?

slide-23
SLIDE 23

Image Gradient

rf = ∂f ∂x, 0

  • rf =

 0, ∂f ∂y

  • rf =

∂f ∂x, ∂f ∂y

  • Gradient in y only

Gradient in x only Gradient in both x and y

Gradient direction Gradient magnitude

θ = tan−1 ✓∂f ∂y /∂f ∂x ◆ ||f|| = s✓∂f ∂x ◆2 + ✓∂f ∂y ◆2

How does the gradient direction relate to the edge? What does a large magnitude look like in the image?

slide-24
SLIDE 24

Common ‘derivative’ filters Prewitt Scharr Roberts Sobel

1

  • 1

2

  • 2

1

  • 1

1 2 1

  • 1
  • 2
  • 1

1

  • 1

1

  • 1

1

  • 1

1 1 1

  • 1
  • 1
  • 1

3

  • 3

10

  • 10

3

  • 3

3 10 3

  • 3 -10 -3

1

  • 1

1

  • 1
slide-25
SLIDE 25

How do you find the edge from this signal?

Intensity plot

slide-26
SLIDE 26

How do you find the edge from this signal?

Intensity plot

Use a derivative filter!

slide-27
SLIDE 27

How do you find the edge from this signal? What happened?

Intensity plot Derivative plot

Use a derivative filter!

slide-28
SLIDE 28

How do you find the edge from this signal?

Derivative filters are sensitive to noise Intensity plot Derivative plot

Use a derivative filter!

slide-29
SLIDE 29

Gaussian

Output Input Smoothed input

Derivative Don’t forget to smooth before running derivative filters!

slide-30
SLIDE 30

A.K.A. Laplacian, Laplacian of Gaussian (LoG), Marr filter, Mexican Hat Function

Laplace filter

slide-31
SLIDE 31

A.K.A. Laplacian, Laplacian of Gaussian (LoG), Marr filter, Mexican Hat Function

Laplace filter

slide-32
SLIDE 32

A.K.A. Laplacian, Laplacian of Gaussian (LoG), Marr filter, Mexican Hat Function

Laplace filter

slide-33
SLIDE 33

f 0(x) = lim

h!0

f(x + 0.5h) − f(x − 0.5h) h

first-order finite difference second-order finite difference

? ? ?

Laplace filter 1

  • 1

derivative filter

slide-34
SLIDE 34

f 0(x) = lim

h!0

f(x + 0.5h) − f(x − 0.5h) h

first-order finite difference second-order finite difference

1

  • 2

1 Laplace filter 1

  • 1

derivative filter

slide-35
SLIDE 35

Laplacian Output Input

?

slide-36
SLIDE 36

Zero crossings are more accurate at localizing edges Second derivative is noisy Laplacian Output Input

slide-37
SLIDE 37

? ? ? ? ? ? ? ? ?

2D Laplace filter 1

  • 2

1 1D Laplace filter

2D Laplace filter

slide-38
SLIDE 38

? ? ? ? ? ? ? ? ?

2D Laplace filter 1

  • 2

1 1D Laplace filter

2D Laplace filter

hint

slide-39
SLIDE 39

1 1

  • 4

1 1 2D Laplace filter 1

  • 2

1 1D Laplace filter

If the Sobel filter approximates the first derivative, the Laplace filter approximates ....?

2D Laplace filter

slide-40
SLIDE 40

with smoothing without smoothing Laplace filter Laplace filter

slide-41
SLIDE 41

Laplace filter Sobel filter What’s different between the two results?

slide-42
SLIDE 42

Laplace Sobel zero-crossing peak

Zero crossings are more accurate at localizing edges

(but not very convenient)

slide-43
SLIDE 43

Gaussian Derivative of Gaussian Laplacian of Gaussian

2D Gaussian Filters