BSB663 Image Processing - Hacettepe

64
BSB663 Image Processing Pinar Duygulu Slides are adapted from Gonzales & Woods, Emmanuel Agu Selim Aksoy 1

Transcript of BSB663 Image Processing - Hacettepe

Page 1: BSB663 Image Processing - Hacettepe

BSB663Image Processing

Pinar Duygulu

Slides are adapted from

Gonzales & Woods,

Emmanuel Agu

Selim Aksoy

1

Page 2: BSB663 Image Processing - Hacettepe

What is an edge?

2

Page 3: BSB663 Image Processing - Hacettepe

3

Edge detection

• Sharp changes in the image brightness occur at:• Object boundaries

• A light object may lie on a dark background or a dark object may lie on a light background.

• Reflectance changes• May have quite different

characteristics – zebrashave stripes, and leopardshave spots.

• Cast shadows

• Sharp changes in surfaceorientation

Page 4: BSB663 Image Processing - Hacettepe

4

Edge models

Page 5: BSB663 Image Processing - Hacettepe

Edge detection

5

Page 6: BSB663 Image Processing - Hacettepe

Characteristics of an Edge

6

Page 7: BSB663 Image Processing - Hacettepe

Characteristics of an Edge

7

Page 8: BSB663 Image Processing - Hacettepe

Characteristics of an Edge

8

Page 9: BSB663 Image Processing - Hacettepe

Slopes of discrete functions

9

Page 10: BSB663 Image Processing - Hacettepe

Computing Derivative of Discrete Function

10

Page 11: BSB663 Image Processing - Hacettepe

Finite differences

11

Page 12: BSB663 Image Processing - Hacettepe

Definition: Function Gradient

12

Page 13: BSB663 Image Processing - Hacettepe

Image Gradient

13

Page 14: BSB663 Image Processing - Hacettepe

Derivative filters

14

Page 15: BSB663 Image Processing - Hacettepe

Finite Differences as Convolutions

15

Page 16: BSB663 Image Processing - Hacettepe

Finite Differences as Convolutions

16

Page 17: BSB663 Image Processing - Hacettepe

x‐Derivative of Image using Central Difference

17

Page 18: BSB663 Image Processing - Hacettepe

y‐Derivative of Image using Central Difference

18

Page 19: BSB663 Image Processing - Hacettepe

19

Page 20: BSB663 Image Processing - Hacettepe

Edge Operators

20

Page 21: BSB663 Image Processing - Hacettepe

21

Page 22: BSB663 Image Processing - Hacettepe

Using Averaging with Derivatives

22

Page 23: BSB663 Image Processing - Hacettepe

Sobel operator

23

Page 24: BSB663 Image Processing - Hacettepe

24

Page 25: BSB663 Image Processing - Hacettepe

Improved Sobel filter

25

Page 26: BSB663 Image Processing - Hacettepe

26

Page 27: BSB663 Image Processing - Hacettepe

Scaling Edge Components

27

Page 28: BSB663 Image Processing - Hacettepe

Gradient‐Based Edge Detection

28

Page 29: BSB663 Image Processing - Hacettepe

29

Difference operators for 2D

Adapted from Gonzales and Woods

Page 30: BSB663 Image Processing - Hacettepe

Gradient‐Based Edge Detection

30

Page 31: BSB663 Image Processing - Hacettepe

Non‐Maxima Suppression

31

Page 32: BSB663 Image Processing - Hacettepe

Non‐Maxima Suppression

32

Page 33: BSB663 Image Processing - Hacettepe

Roberts Edge Operators

33

Page 34: BSB663 Image Processing - Hacettepe

Roberts Edge Operators

34

Page 35: BSB663 Image Processing - Hacettepe

Recall: Characteristics of an Edge

35

Page 36: BSB663 Image Processing - Hacettepe

Other Edge Operators

36

Page 37: BSB663 Image Processing - Hacettepe

37

Difference operators under noiseConsider a single row or column of the image.Where is the edge?

Adapted from Steve Seitz

Page 38: BSB663 Image Processing - Hacettepe

38

Difference operators under noiseSolution is to smooth first:

Adapted from Steve Seitz

Page 39: BSB663 Image Processing - Hacettepe

39

Difference operators under noiseDifferentiation property of convolution:

Adapted from Steve Seitz

Page 40: BSB663 Image Processing - Hacettepe

40

Difference operators under noiseConsider:

Adapted from Steve Seitz

Laplacian of Gaussian

operator

Page 41: BSB663 Image Processing - Hacettepe

Edge detection filters for 2D

41

Laplacian of Gaussian

Gaussian derivative of Gaussian

Adapted from Steve Seitz, U of Washington

Page 42: BSB663 Image Processing - Hacettepe

42

Difference operators for 2D

Page 43: BSB663 Image Processing - Hacettepe

43

Difference operators for 2D

Page 44: BSB663 Image Processing - Hacettepe

44

Difference operators for 2D

sigma=2

sigma=4

Threshold=1 Threshold=4

Laplacian of Gaussianzero crossings

Adapted from David Forsyth, UC Berkeley

Page 45: BSB663 Image Processing - Hacettepe

Edges at different scales

45

Page 46: BSB663 Image Processing - Hacettepe

Canny Edge Detector

46

Page 47: BSB663 Image Processing - Hacettepe

47

Page 48: BSB663 Image Processing - Hacettepe

48

Page 49: BSB663 Image Processing - Hacettepe

49

Edge detection

• Three fundamental steps in edge detection:

1. Image smoothing: to reduce the effects of noise.

2. Detection of edge points: to find all image points that are potential candidates to become edge points.

3. Edge localization: to select from the candidate edge points only the points that are true members of an edge.

Page 50: BSB663 Image Processing - Hacettepe

50

Canny edge detector

• Canny defined three objectives for edge detection:1. Low error rate: All edges should be found and there should be no spurious

responses.

2. Edge points should be well localized: The edges located must be as close as possible to the true edges.

3. Single edge point response: The detector should return only one point for each true edge point. That is, the number of local maxima around the true edge should be minimum.

Page 51: BSB663 Image Processing - Hacettepe

51

Canny edge detector1. Smooth the image with a Gaussian filter with spread

σ.

2. Compute gradient magnitude and direction at each pixel of the smoothed image.

3. Zero out any pixel response less than or equal to the two neighboring pixels on either side of it, along the direction of the gradient (non-maxima suppression).

4. Track high-magnitude contours using thresholding (hysteresis thresholding).

5. Keep only pixels along these contours, so weak little segments go away.

Page 52: BSB663 Image Processing - Hacettepe

Canny edge detector

52

Original image (Lena)

Adapted from Steve Seitz, U of Washington

Page 53: BSB663 Image Processing - Hacettepe

Canny edge detector

53Adapted from Steve Seitz, U of Washington

Magnitude of the gradient

Page 54: BSB663 Image Processing - Hacettepe

Canny edge detector

54Adapted from Steve Seitz, U of Washington

Thresholding

Page 55: BSB663 Image Processing - Hacettepe

Canny edge detector

55Adapted from Steve Seitz, U of Washington

How to turn these thick regions of the gradient into curves?

Page 56: BSB663 Image Processing - Hacettepe

56

Canny edge detector• Non-maxima suppression:

• Check if pixel is local maximum along gradient direction.

• Select single max across width of the edge.

• Requires checking interpolated pixels p and r.

• This operation can be used with any edge operator when thin boundaries are wanted.

Page 57: BSB663 Image Processing - Hacettepe

Canny edge detector

57Adapted from Steve Seitz, U of Washington

Problem: pixels along this edge did not survive the thresholding

Page 58: BSB663 Image Processing - Hacettepe

58

Canny edge detector

• Hysteresis thresholding:• Use a high threshold to start edge curves, and a low threshold to continue

them.

Page 59: BSB663 Image Processing - Hacettepe

59

Canny edge detector

Adapted from Martial Hebert, CMU

Page 60: BSB663 Image Processing - Hacettepe

60

Canny edge detector

Page 61: BSB663 Image Processing - Hacettepe

61

Canny edge detector

Page 62: BSB663 Image Processing - Hacettepe

62

Canny edge detector

• The Canny operator gives single-pixel-wide images with good continuation between adjacent pixels.

• It is the most widely used edge operator today; no one has done better since it came out in the late 80s. Many implementations are available.

• It is very sensitive to its parameters, which need to be adjusted for different application domains.

Page 63: BSB663 Image Processing - Hacettepe

From Edges to Contours

63

Page 64: BSB663 Image Processing - Hacettepe

Edge Maps

64