- ? Edge detection Goal : - - PowerPoint PPT Presentation

edge detection
SMART_READER_LITE
LIVE PREVIEW

- ? Edge detection Goal : - - PowerPoint PPT Presentation

- ? Edge detection Goal : map image from 2d array of pixels to a set of curves or line segments or contours. Why? Figure from J. Shotton et al., PAMI 2007 Main idea :


slide-1
SLIDE 1

רותיא- ףס– יאהנומתב םיוקה םירבוע הפ?

slide-2
SLIDE 2

Edge detection

  • Goal: map image from 2d array of pixels to a set of curves
  • r line segments or contours.
  • Why?
  • Main idea: look for strong gradients, post-process

Figure from J. Shotton et al., PAMI 2007

slide-3
SLIDE 3

What can cause an edge?

Depth discontinuity:

  • bject boundary

Change in surface

  • rientation: shape

Cast shadows Reflectance change: appearance information, texture

slide-4
SLIDE 4

Recall : Images as functions

  • Edges look like steep cliffs

Source: S. Seitz

slide-5
SLIDE 5

Derivatives and edges

image intensity function (along horizontal scanline) first derivative edges correspond to extrema of derivative

Source: L. Lazebnik

An edge is a place of rapid change in the image intensity function.

slide-6
SLIDE 6

Differentiation and convolution

For 2D function, f(x,y), the partial derivative is: For discrete data, we can approximate using finite differences: To implement above as convolution, what would be the associated filter?

 

) , ( ) , ( lim ) , ( y x f y x f x y x f     

1 ) , ( ) , 1 ( ) , ( y x f y x f x y x f     

slide-7
SLIDE 7
  • First, consider a signal in 1D…
  • Let’s replace each pixel with an average of all

the values in its neighborhood

  • Moving average in 1D:

Side note: Filters and Convolutions

Source: S. Marschner

slide-8
SLIDE 8

Weighted Moving Average

  • Can add weights to our moving average
  • Weights [1, 1, 1, 1, 1] / 5

Source: S. Marschner

slide-9
SLIDE 9

Weighted Moving Average

  • Non-uniform weights [1, 4, 6, 4, 1] / 16

Source: S. Marschner

slide-10
SLIDE 10

Moving Average In 2D

90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90

Source: S. Seitz

slide-11
SLIDE 11

Moving Average In 2D

90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 10 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90

Source: S. Seitz

slide-12
SLIDE 12

Moving Average In 2D

90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 10 20 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90

Source: S. Seitz

slide-13
SLIDE 13

Moving Average In 2D

90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 10 20 30 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90

Source: S. Seitz

slide-14
SLIDE 14

Moving Average In 2D

10 20 30 30 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90

Source: S. Seitz

slide-15
SLIDE 15

Moving Average In 2D

90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 10 20 30 30 30 20 10 20 40 60 60 60 40 20 30 60 90 90 90 60 30 30 50 80 80 90 60 30 30 50 80 80 90 60 30 20 30 50 50 60 40 20 10 20 30 30 30 30 20 10 10 10 10

Source: S. Seitz

slide-16
SLIDE 16

Correlation filtering

Say the averaging window size is 2k+1 x 2k+1:

Loop over all pixels in neighborhood around image pixel F[i,j] Attribute uniform weight to each pixel

Now generalize to allow different weights depending on neighboring pixel’s relative position:

Non-uniform weights

slide-17
SLIDE 17

Correlation filtering

Filtering an image: replace each pixel with a linear combination of its neighbors. The filter “kernel” or “mask” H[u,v] is the prescription for the weights in the linear combination. This is called cross-correlation, denoted

slide-18
SLIDE 18

Averaging filter

  • What values belong in the kernel H for the moving average

example?

10 20 30 30 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90

1 1 1 1 1 1 1 1 1 “box filter”

?

slide-19
SLIDE 19

Smoothing by averaging

depicts box filter: white = high value, black = low value

  • riginal

filtered

slide-20
SLIDE 20

Gaussian filter

0 90 90 90 90 90 0 0 90 90 90 90 90 0 0 90 90 90 90 90 0 0 90 0 90 90 90 0 0 90 90 90 90 90 0 0 90 0 1 2 1 2 4 2 1 2 1

  • What if we want nearest neighboring pixels to have the

most influence on the output? This kernel is an approximation of a Gaussian function:

Source: S. Seitz

slide-21
SLIDE 21

Smoothing with a Gaussian

slide-22
SLIDE 22

Gaussian filters

  • What parameters matter here?
  • Size of kernel or mask

– Note, Gaussian function has infinite support, but discrete filters use finite kernels

σ = 5 with 10 x 10 kernel σ = 5 with 30 x 30 kernel

slide-23
SLIDE 23

Gaussian filters

  • What parameters matter here?
  • Variance of Gaussian: determines extent of

smoothing σ = 2 with 30 x 30 kernel σ = 5 with 30 x 30 kernel

slide-24
SLIDE 24

Matlab

>> hsize = 10; >> sigma = 5; >> h = fspecial(‘gaussian’ hsize, sigma); >> mesh(h); >> imagesc(h); >> outim = imfilter(im, h); >> imshow(outim);

  • utim
slide-25
SLIDE 25

Smoothing with a Gaussian

for sigma=1:3:10 h = fspecial('gaussian‘, fsize, sigma);

  • ut = imfilter(im, h);

imshow(out); pause; end

Parameter σ is the “scale” / “width” / “spread” of the Gaussian kernel, and controls the amount of smoothing.

slide-26
SLIDE 26

Predict the filtered outputs

1

* = ?

1

* = ?

1 1 1 1 1 1 1 1 1 2

  • *

= ?

slide-27
SLIDE 27

Practice with linear filters

1 Original

?

Source: D. Lowe

slide-28
SLIDE 28

Practice with linear filters

1 Original Filtered (no change)

Source: D. Lowe

slide-29
SLIDE 29

Practice with linear filters

1 Original

?

Source: D. Lowe

slide-30
SLIDE 30

Practice with linear filters

1 Original Shifted left by 1 pixel with correlation

Source: D. Lowe

slide-31
SLIDE 31

Practice with linear filters

Original

?

1 1 1 1 1 1 1 1 1

Source: D. Lowe

slide-32
SLIDE 32

Practice with linear filters

Original 1 1 1 1 1 1 1 1 1 Blur (with a box filter)

Source: D. Lowe

slide-33
SLIDE 33

Practice with linear filters

Original 1 1 1 1 1 1 1 1 1 2

  • ?

Source: D. Lowe

slide-34
SLIDE 34

Practice with linear filters

Original 1 1 1 1 1 1 1 1 1 2

  • Sharpening filter
  • Accentuates differences with

local average

Source: D. Lowe

slide-35
SLIDE 35

Filtering examples: sharpening

slide-36
SLIDE 36

Convolution

  • Convolution:

– Flip the filter in both dimensions (bottom to top, right to left) – Then apply cross-correlation

Notation for convolution

  • perator

F H

slide-37
SLIDE 37

Convolution vs. correlation

Convolution Cross-correlation

Back to our question: To implement the derivates, what would be the associated filter?

1 ) , ( ) , 1 ( ) , ( y x f y x f x y x f     

slide-38
SLIDE 38

Partial derivatives of an image

Which shows changes with respect to x?

  • 1

1

  • 1 1

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

slide-39
SLIDE 39

Assorted finite difference filters

>> My = fspecial(‘sobel’); >> outim = imfilter(double(im), My); >> imagesc(outim); >> colormap gray;

slide-40
SLIDE 40

Image gradient

The gradient of an image: The gradient points in the direction of most rapid change in intensity The gradient direction (orientation of edge normal) is given by: The edge strength is given by the gradient magnitude

Slide credit S. Seitz

slide-41
SLIDE 41
slide-42
SLIDE 42
slide-43
SLIDE 43
slide-44
SLIDE 44
slide-45
SLIDE 45
slide-46
SLIDE 46
slide-47
SLIDE 47
slide-48
SLIDE 48

Issues to Address: The effects of noise

Consider a single row or column of the image

– Plotting intensity as a function of position gives a signal

Where is the edge?

slide-49
SLIDE 49

Where is the edge?

Solution: smooth first

Look for peaks in

slide-50
SLIDE 50

Derivative theorem of convolution

Differentiation property of convolution.

slide-51
SLIDE 51

Derivative of Gaussian filter

 

1 1  

 

0.0030 0.0133 0.0219 0.0133 0.0030 0.0133 0.0596 0.0983 0.0596 0.0133 0.0219 0.0983 0.1621 0.0983 0.0219 0.0133 0.0596 0.0983 0.0596 0.0133 0.0030 0.0133 0.0219 0.0133 0.0030

) ( ) ( h g I h g I     

slide-52
SLIDE 52

Derivative of Gaussian filters

x-direction y-direction

Source: L. Lazebnik

slide-53
SLIDE 53

Smoothing with a Gaussian

Parameter σ is the “scale” / “width” / “spread” of the Gaussian kernel, and controls the amount of smoothing.

slide-54
SLIDE 54

Effect of σ on derivatives

The apparent structures differ depending on Gaussian’s scale parameter. Larger values: larger scale edges detected Smaller values: finer features detected

σ = 1 pixel σ = 3 pixels

slide-55
SLIDE 55

So, what scale to choose?

It depends what we’re looking for. Too fine of a scale…can’t see the forest for the trees. Too coarse of a scale…can’t tell the maple grain from the cherry.

slide-56
SLIDE 56
slide-57
SLIDE 57
slide-58
SLIDE 58
slide-59
SLIDE 59
slide-60
SLIDE 60
slide-61
SLIDE 61
slide-62
SLIDE 62
slide-63
SLIDE 63
slide-64
SLIDE 64

Edge detection is just the beginning…

Berkeley segmentation database:

http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/segbench/

image human segmentation gradient magnitude

Source: L. Lazebnik

Much more on segmentation later…