edge detection - haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · edge linking hough transform edge...

27
Image Processing - Lesson 9 Edge detection masks Gradient Detectors Compass Detectors Second Derivative - Laplace detectors Edge Linking Hough Transform Edge Detection

Upload: lyhanh

Post on 17-Apr-2018

226 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

Image Processing - Lesson 9

Edge detection masks

Gradient Detectors

Compass Detectors

Second Derivative - Laplace detectors

Edge Linking

Hough Transform

Edge Detection

Page 2: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

Image Processing

Computer Vision

Low Level

High Level

Image Processing - Computer Vision

representation,compression,transmission

image enhancement

edge/feature finding

image "understanding"

Page 3: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

UFO - Unidentified Flying Object

Page 4: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

Point Detection

Convolution with:-1 -1 -1 -1 8 -1 -1 -1 -1

Large Positive values = light point on dark surroundLarge Negative values = dark point on light surround

Example:

-1 -1 -1 -1 8 -1 -1 -1 -1

5 5 5 5 5 5 5 5 100 55 5 5 5 5

0 0 -95 -95 -95 0 0 -95 760 -950 0 -95 -95 -95

*

=

Page 5: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

Edge Definition

Line Edgegr

ay v

alue

x

edge edge

gray

val

ue

x

edge edge

Step Edge

Page 6: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

Edge Detection

Line Edge Detectors

Step Edge Detectors

-1 -1 -1 2 2 2 -1 -1 -1

-1 2 -1 -1 2 -1 -1 2 -1

2 -1 -1 -1 2 -1-1 -1 2

-1 -1 2 -1 2 -1 2 -1 -1

-1 1-1 1-1 1

-1 -1 1 1 -1 -1 1 1-1 -1 1 1-1 -1 1 1

-1 -1 -1 -1-1 -1 -1 -11 1 1 11 -1 1 1

-1 -1 -1 -11 1 1 1

Page 7: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

Edge Detection by Differentiation

Step Edge detection by differentiation:

gray

val

ue

x

1D image f(x)

1st derivative f'(x)

threshold|f'(x)| - threshold

Pixels that passed the threshold are

Edge Pixels

Page 8: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

Gradient Edge Detection

∇ f((x,y) =

∂f∂x∂f∂y

Gradient

Gradient Magnitude

Gradient Direction

∂f∂x

∂f∂y√( )2 + ( )2

∂f∂y

∂f∂xtg-1 ( / )

Page 9: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

Differentiation in Digital Images

∂f(x,y)∂x = f(x,y) - f(x-1,y)

= f(x,y) - f(x,y-1)∂f(x,y)

∂y

horizontal - differentiation approximation:

vertical - differentiation approximation:

convolution with [ 1 -1 ]

convolution with 1-1

FA =

FB =

Gradient (FA , FB)

((FA )2 + (FB)2 )1/2Magnitude

|FA | + |FB|Approx. Magnitude

Page 10: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

FA = f(x,y) - f(x-1,y-1)

FB = f(x-1,y) - f(x,y-1)

1 00 -1A = 0 1

-1 0B =

Roberts and other 2x2 operators are sensitive to noise.

Roberts Edge Detector

Smoothed operators

Prewitt Edge Detector

-1 -1 -10 0 01 1 1

B =-1 0 1-1 0 1-1 0 1

A =

Page 11: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

Sobel Edge Detector

-1 -2 -10 0 01 2 1

B =-1 0 1-2 0 2-1 0 1

A =

Isotropic Edge Detector

-1 -√2 -10 0 01 √2 1

B =-1 0 1-√2 0 √2-1 0 1

A =

Page 12: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

Example Edge

Original

Gradient-X Gradient-Y

Gradient-Magnitude Gradient-Direction

Page 13: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

Compass Operators

1 1 1 0 0 0 -1 -1 -1

-1 -1 -1 0 0 0 1 1 1

1 1 0 1 0 -10 -1 -1

-1 -1 0 -1 0 10 1 1

1 0 -1 1 0 -11 0 -1

-1 0 1 -1 0 1-1 0 1

0 -1 -1 1 0 -11 1 0

0 1 1 -1 0 1-1 -1 0

N

S

NW

SE

W SW

E NE

Given k operators, gk(x,y) is the image obtained byconvolving f(x,y) with the kth operator.

The gradient is defined as:

g(x,y) = max gk(x,y)k

k defines the edge direction

Page 14: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

Various Compass Operators:

1 1 1 1 -2 1 -1 -1 -1

Kirsch Edge Detector

1 1 1 0 0 0-1 -1 -1

5 5 5 -3 0 -3-3 -3 -3

1 2 1 0 0 0-1 -2 -1

Page 15: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

f(x)

f (x)

f (x)

Derivatives

zero crossing

Page 16: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

Laplacian Operators

Approximation of second derivative (horizontal):

= f''(x,y) = f'(x+1,y) - f'(x,y) =

= [f(x+1,y) - f(x,y)] - [f(x,y) - f(x-1,y)] = f(x+1,y) - 2 f(x,y) + f(x-1,y)

∂f2(x,y)∂2x

convolution with: [ 1 -2 1]

Approximation of second derivative (vertical):

convolution with: 1-21

Laplacian Operator ( + )∇2 = ∂2

∂x2∂2

∂y2

convolution with:0 -1 0-1 4 -10 -1 0

Page 17: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

Variations on Laplace Operators:

0 -1 0-1 4 -10 -1 0

1 -2 1-2 4 -21 -2 1

-1 -1 -1-1 8 -1-1 -1 -1

All are approximations of:

Page 18: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

Example of Laplacian Edge Detection

Page 19: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

- =

Laplacian ~ Difference of Gaussians

DOG = Difference of Gaussians

Page 20: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

FFT

- =

FFT

- =

Laplacian Operator(Image Domain)

Laplacian Filter(Frequency Domain)

Page 21: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

Enhancement Using the Laplacian Operator

Edge Image f(x)

∂f∂x1st derivative

∂2f∂x2

2nd derivative(Laplacian)

∂2f∂x2-

∂2f∂x2f(x) -

Mach Bands

Page 22: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

Edge Linking

(x,y) is an edge pixel.Search for neighboring edge pixels that are "similar".

Similarity:

Similarity in Edge OrientationSimilarity in Edge strength (Gradient Amplitude)

Perform Edge Following along similar edge pixels.(as in Contour Following in binary images).

Page 23: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

θ

Hough Transform

x

ys (θ, s)

straight line Hough Transform

x

y

single point = many possible lines

θ

s

Image Domain Hough Domain

Page 24: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

x

y

many points on a line = many lines in the Hough transform space which intersect at 1 point.

s

Hough transform Method for finding line segments

θ

Page 25: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

Hough Transform Example

Hough Transform (s,θ) space

Original square image

s

θ

Reconstructed line segments

Page 26: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

Hough Transform Example

Original Edges

Hough Transform

Results1 Results2 Results3

Page 27: Edge Detection - Haifacs.haifa.ac.il/~dkeren/ip/lecture9.pdf · Edge Linking Hough Transform Edge Detection. Image Processing Computer Vision Low Level High Level ... Prewitt Edge

Hough Transform Example

Original

Edges

Result