lecture # 13 image segmentation & hough transform · 2017-04-20 · 1/14/2017 image...

69
1 Digital Image Processing Lecture # 13 Image Segmentation & Hough Transform

Upload: others

Post on 18-Mar-2020

3 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1

Digital Image Processing

Lecture # 13 Image Segmentation & Hough Transform

Page 2: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

Image Segmentation

Page 3: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 3

Image Segmentation

Group similar components (such as, pixels in an

image, image frames in a video)

Applications: Finding tumors, veins, etc. in medical

images, finding targets in satellite/aerial images,

finding people in surveillance images, summarizing

video, etc.

Page 4: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 4

Image Segmentation

Segmentation algorithms are based on one of two basic

properties of gray-scale values:

Discontinuity

Partition an image based on abrupt changes in gray-scale levels.

Detection of isolated points, lines, and edges in an image.

Similarity

Thresholding, region growing, and region splitting/merging.

Page 5: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 5

Thresholding Segmentation into two classes/groups

Foreground (Objects)

Background

Page 6: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 6

Thresholding

1 ( , )( , )

0 ( , )

if f x y Tg x y

if f x y T

Objects & Background

Global Thresholding

Local/Adaptive Thresholding

Page 7: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 7

Global Thresholding Single threshold value for entire image

Fixed ?

Automatic

Intensity histogram

Page 8: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 8

Global Thresholding Single threshold value for entire image

Fixed ?

Automatic

Intensity histogram

Page 9: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 9

Global Thresholding

Estimate an initial T

Segment Image using T: Two groups of pixels G1 and G2

Compute average gray values m1 and m2 of two groups

Compute new threshold value T=1/2(m1+m2)

Repeat steps 2 to 4 until: abs(Ti – Ti-1)<epsilon

Page 10: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 10

Global Thresholding

Multilevel thresholding

Page 11: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 11

Thresholding Non-uniform illumination:

Page 12: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 12

Global Thresholding

Page 13: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 13

Adaptive Thresholding

Page 14: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 14

Adaptive Thresholding Threshold: function of neighboring pixels

max min

2

T mean

T median

T

Page 15: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 15

Adaptive Thresholding

Original Image Global Thresholding

Page 16: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 16

Adaptive Thresholding

T=mean, neighborhood=7x7 T=mean-Const., neighborhood=7x7

Page 17: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 17

Adaptive Thresholding

mean

standard deviations

Niblack constant

T m k s

m

s

k

Niblack Algorithm

Neighborhood size???

Page 18: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

Document Binarization

• Local Thresholding – Examples

18

Original Niblack Sauvola

Wolf Feng NICK

Page 19: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 19

Region-Based Segmentation Divide the image into regions

R1,R2,…,RN

Following properties must hold:

(For adjacent regions)

Page 20: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 20

Region-Based Segmentation Region Growing

Region growing: groups pixels or subregions into larger

regions.

Pixel aggregation: starts with a set of “seed” points and from

these grows regions by appending to each seed points those

neighboring pixels that have similar properties (such as gray

level).

Predicate: for example abs(zj - seed) < Epsilon

1. Choose the seed pixel(s).

2. Check the neighboring pixels and add them to the region if they are

similar to the seed

3. Repeat step 2 for each of the newly added pixels; stop if no more

pixels can be added

Page 21: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 21

Region-Based Segmentation Example

Page 22: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 22

Region-Based Segmentation Region Splitting

Region Growing: Starts from a set of seed points.

Region Splitting: Starts with the whole image as a single

region and subdivide the regions that do not satisfy a

condition.

Image = One Region R

Select a predicate P (gray values etc.)

Successively divide each region into smaller and smaller

quadrant regions so that:

( )iP R true

Page 23: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 23

Region-Based Segmentation Region Splitting

Problem? Adjacent regions could be same

Solution? Allow Merge

Page 24: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 24

Region-Based Segmentation

Region Merging

Region merging is the opposite of region splitting.

Merge adjacent regions Ri and Rj for which:

Region Splitting/Merging

Stop when no further split or merge is possible

( )i jP R R True

Page 25: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 25

Region-Based Segmentation

1. Split into four disjointed quadrants any region Ri where P(Ri)=False

2. Merge any adjacent regions Rj and Rk for which P(Rj U Rk)=True

3. Stop when no further merging or splitting is possible

Example

Page 26: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

Clustering

Page 27: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 27

K-Means Clustering 1. Chose the number (K) of clusters and randomly select the

centroids of each cluster.

2. For each data point:

Calculate the distance from the data point to each cluster.

Assign the data point to the closest cluster.

3. Recompute the centroid of each cluster.

4. Repeat steps 2 and 3 until there is no further change in

the assignment of data points (or in the centroids).

Page 28: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 28

K-Means Clustering

Page 29: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 29

K-Means Clustering

Page 30: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 30

K-Means Clustering

Page 31: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 31

K-Means Clustering

Page 32: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 32

K-Means Clustering

Page 33: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 33

K-Means Clustering

Page 34: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 34

K-Means Clustering

Page 35: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 35

K-Means Clustering

Page 36: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 36

K-Means Clustering

Page 37: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 37

Clustering Example

Page 38: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 38

Clustering Example

Page 39: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 39

Clustering Example

Page 40: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 40

Clustering Example

Page 41: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 41

Clustering Example

D. Comaniciu and P.

Meer, Robust Analysis

of Feature Spaces:

Color Image

Segmentation, 1997.

Page 42: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

1/14/2017 Image Segmentation 42

K-Means Clustering Example

Original K=5 K=11

Page 43: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

Hough Transform

Page 44: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

44

Page 45: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

45

Page 46: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

46

Page 47: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

47

Page 48: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

48

Page 49: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

49

Page 50: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties
Page 51: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties
Page 52: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties
Page 53: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

53

Page 54: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

54

Hough Transform • The edge points are linked by determining if they lie on a curve of

specified shape.

• Let us take the case of straight lines: we want to link points if they lie on a straight line.

• Consider a point (xi,yi), the equation of any line passing through this point is given by: yi = a xi + b, which can be written as: b = - xia + yi. Therefore every point in xy plane corresponds to a straight line in ab plane.

• If there is a second point (xj,yj), another line with equation: b = - xja + yj is drawn in the ab plane.

• The intersection of the two lines in ab space give the values of (a/,b/), which define a line passing through both points (xi,yi) and (xj,yj).

Page 55: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

55

Hough Transform

Implementation

The parameter space ab is subdivided into the accumulator cells, where (amax,amin) and (bmax,bmin) are the expected ranges of slope and intercept values.

Page 56: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

56

Hough Transform Implementation steps:

• Initially the accumulator cells are set to zero.

• Then for every point (xk,yk) in the image, a is varied over the allowed subdivision values and the corresponding b values are calculated using b = -xka + yk.

• The resulting b are then rounded off to the allowed values of b.

• If a value of ap results in solution bq, we let the corresponding accumulator value A(p,q) = A(p,q) +1.

• In the end the value of Q in A(i,j) corresponds to Q points on the line y = -aix + bj.

Note: The number of subdivisions in the ab plane determines the accuracy of the colinearity of these points.

Page 57: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

57

Hough Transform Implementation 1 0 0 0 0 0 0

0 1 0 0 0 0 0

0 0 1 0 0 0 0

0 0 0 1 0 0 0

0 0 0 1 0 0 0

0 0 0 0 0 1 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

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

-2

-1

0

1

2

3

0 0 0 1 0 0 0

0 0 0 1 0 0 0

0 0 0 1 0 0 0

0 0 0 1 0 0 0

0 0 0 1 0 0 0

0 0 0 1 0 0 0

0 0 0 1 0 0 0

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

-2

-1

0

1

2

3

0 0 0 1 0 0 0

0 0 0 1 0 0 1

0 0 0 1 0 1 0

0 0 0 1 1 0 0

0 0 0 2 0 0 0

0 0 1 1 0 0 0

0 1 0 1 0 0 0

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

-2

-1

0

1

2

3

0 0 0 1 0 0 0

0 0 0 1 0 0 1

0 0 0 1 0 1 0

0 0 0 1 1 1 0

0 0 0 3 0 0 0

0 1 1 1 0 0 0

0 1 0 1 0 0 0

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

-2

-1

0

1

2

3

0 0 0 1 0 0 0

0 0 0 1 0 0 1

0 0 0 1 0 1 0

0 0 0 1 1 1 2

0 0 1 5 0 0 0

1 1 1 1 0 0 0

0 1 0 1 0 0 0

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

-2

-1

0

1

2

3

….

Parameters a and b can take values between –infinity to +infinity

Page 58: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

58

Hough Transform • Limitation in using yi = a xi + b, as the representation of

straight line is that slope approaches to infinity as the line approaches to be vertical.

• Therefore usually Hough Transform is implemented using the polar equation of straight line, i.e.

and instead of ab-plane rq-plane is used.

• Every point in image gives a sinusoidal curve in the rq-plane.

rqq sincos yx

Page 60: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

60

Hough Transform

Page 61: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

Hough Transform

Page 62: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

Example

62

Page 63: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties
Page 64: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

64

Hough Transform

Page 65: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

65

Implementation of the Hough transform • Construct an array representing q, r

• For each point, render the curve (q, r) into this array, adding one at each cell

• Difficulties

– how big should the cells be? (too big, and we cannot distinguish between quite different lines; too small, and noise causes lines to be missed)

• How many lines?

– count the peaks in the Hough array

• This method can be extended to other type of curves also by using the equation for the desired curve, e.g. circle:

2

3

2

2

2

1 )()( ccycx

Page 66: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

66

Hough Transform

Page 67: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

67

Hough Transform

Page 68: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

68

Two main limitations:noise and cell size

Noise Limitations of Hough Transform

Results for a specimen of line with 20 points, with different amounts of

noise

Page 69: Lecture # 13 Image Segmentation & Hough Transform · 2017-04-20 · 1/14/2017 Image Segmentation 4 Image Segmentation Segmentation algorithms are based on one of two basic properties

69

Acknowledgements

Digital Image Processing”, Rafael C. Gonzalez & Richard E. Woods, Addison-Wesley, 2002

Computer Vision for Computer Graphics, Mark Borg

Mat

eria

l in

th

ese

slid

es h

as b

een

tak

en f

rom

, th

e fo

llow

ing

reso

urc

es