Image Processing

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

Image Processing - Lesson 9

Edge Detection
Edge detection masks
Gradient Detectors
Compass Detectors
Second Derivative - Laplace detectors

Edge Linking
Hough Transform

Image Processing - Computer Vision


Low Level

Image Processing

representation,
compression,transmission

image enhancement

edge/feature finding

Computer Vision

image "understanding"

High Level

UFO - Unidentified Flying Object

Point Detection
-1 -1 -1
-1 8 -1
-1 -1 -1

Convolution with:

Large Positive values = light point on dark surround


Large Negative values = dark point on light surround

Example:
5
5
5

5
5
5

5 5 5
5 100 5
5 5 5

0
0
0

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

0 -95 -95 -95


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

Edge Definition

gray value

Line Edge

x
edge

edge

gray value

Step Edge

x
edge

edge

Edge Detection

Line Edge Detectors


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

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

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

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

Step Edge Detectors


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

-1
-1
1
1

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

Edge Detection by Differentiation

1D image f(x)

gray value

Step Edge detection by differentiation:

1st derivative f'(x)

|f'(x)| - threshold

Pixels that passed


the threshold are
Edge Pixels

threshold

Gradient Edge Detection

Gradient

Gradient Magnitude

Gradient Direction

f
x
f((x,y) =
f
y

f )2 + ( f )2
( x
y

tg-1 (

f
y

f
/ x
)

Differentiation in Digital Images


horizontal - differentiation approximation:

FA =

f(x,y)
x

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

convolution with

[ 1 -1 ]

vertical - differentiation approximation:

FB =

f(x,y)
y

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

convolution with

Gradient
Magnitude
Approx. Magnitude

1
-1

(FA , F B)
((FA )2 + (FB)2 )1/2
|FA | + |F B|

Roberts Edge Detector


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

A=

1 0
0 -1

B=

0 1
-1 0

Roberts and other 2x2 operators are sensitive to noise.

Prewitt Edge Detector

A=

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

B=

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

Smoothed operators

Sobel Edge Detector

A=

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

B=

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

Isotropic Edge Detector

A=

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

B=

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

Example Edge

Original

Gradient-X

Gradient-Y

Gradient-Magnitude

Gradient-Direction

Compass Operators
1 1 1
0 0 0
-1 -1 -1
N
-1 -1 -1
0 0 0
1 1 1
S

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

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

NW

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

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

SE

0 -1 -1
1 0 -1
1 1 0
SW
0 1 1
-1 0 1
-1 -1 0
NE

Given k operators, gk(x,y) is the image obtained by


convolving 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

Various Compass Operators:

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

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

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

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

Kirsch Edge Detector

Derivatives

f(x)

f (x)

f (x)

zero crossing

Laplacian Operators
Approximation of second derivative (horizontal):
f 2(x,y)
2x = 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)
convolution with:

[ 1 -2 1]

Approximation of second derivative (vertical):


convolution with:

Laplacian Operator

convolution with:

1
-2
1

2 2
= ( x2 +y2)

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

Variations on Laplace Operators:


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

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

All are approximations of:

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

Example of Laplacian Edge Detection

Laplacian ~ Difference of Gaussians

DOG = Difference of Gaussians

Laplacian Operator
(Image Domain)

Laplacian Filter
(Frequency Domain)

FFT

=
FFT

Enhancement Using the Laplacian Operator

Edge Image f(x)

f
1st derivative x

2nd derivative 2f
(Laplacian) x2

2f

- 2
x

2
f(x) - f2
x

Mach Bands

Edge Linking
(x,y) is an edge pixel.
Search for neighboring edge pixels that are "similar".
Similarity:
Similarity in Edge Orientation
Similarity in Edge strength (Gradient Amplitude)

Perform Edge Following along similar edge pixels.


(as in Contour Following in binary images).

Hough Transform
Image Domain

Hough Domain

(, s)

straight line

Hough Transform

single point = many possible lines

Hough transform Method


for finding line segments

many points on a line =


many lines in the Hough transform space which
intersect at 1 point.

Hough Transform Example

Original
square image

Hough Transform
(s,) space

Reconstructed
line segments

Hough Transform Example


Original

Edges

Hough Transform

Results1

Results2

Results3

Hough Transform Example

Original

Edges

Result

You might also like