Lecture # 7 Hough Transform, Segmentation & Morphological...

79
1 Digital Image Processing Lecture # 7 Hough Transform, Segmentation & Morphological Operations

Transcript of Lecture # 7 Hough Transform, Segmentation & Morphological...

Page 1: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

1

Digital Image Processing

Lecture # 7Hough Transform, Segmentation & Morphological

Operations

Page 2: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

2

Page 3: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

3

Page 4: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

4

Page 5: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

5

Page 6: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

6

Page 7: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

7

Page 8: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

8

Page 9: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

9

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 10: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

10

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 11: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells
Page 12: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells
Page 13: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells
Page 14: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

14

Hough TransformImplementation 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 15: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

15

Hough Transform Implementation1 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 16: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

16

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 17: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

17

Hough Transform

Page 18: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

18

Page 19: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells
Page 20: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

20

Hough Transform

Page 21: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

21

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 22: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

22

Hough Transform

Page 23: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

23

Hough Transform

Page 24: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

24

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 25: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

25

Hough Transform

Page 26: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

Image Segmentation

Page 27: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

11/8/2014 Image Segmentation 27

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 28: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

11/8/2014 Image Segmentation 28

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 29: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

11/8/2014 Image Segmentation 29

Thresholding Segmentation into two classes/groups

Foreground (Objects)

Background

Page 30: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

11/8/2014 Image Segmentation 30

Thresholding

1 ( , )( , )

0 ( , )

if f x y Tg x y

if f x y T

Objects & Background

Global Thresholding

Local/Adaptive Thresholding

Page 31: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

11/8/2014 Image Segmentation 31

Global Thresholding Single threshold value for entire image

Fixed ?

Automatic

Intensity histogram

Page 32: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

11/8/2014 Image Segmentation 32

Global Thresholding Single threshold value for entire image

Fixed ?

Automatic

Intensity histogram

Page 33: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

11/8/2014 Image Segmentation 33

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 34: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

11/8/2014 Image Segmentation 34

Global Thresholding

Multilevel thresholding

Page 35: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

11/8/2014 Image Segmentation 35

Thresholding Non-uniform illumination:

Page 36: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

11/8/2014 Image Segmentation 36

Global Thresholding

Page 37: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

11/8/2014 Image Segmentation 37

Adaptive Thresholding

Page 38: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

11/8/2014 Image Segmentation 38

Adaptive Thresholding Threshold: function of neighboring pixels

max min

2

T mean

T median

T

Page 39: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

11/8/2014 Image Segmentation 39

Adaptive Thresholding

Original Image Global Thresholding

Page 40: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

11/8/2014 Image Segmentation 40

Adaptive Thresholding

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

Page 41: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

11/8/2014 Image Segmentation 41

Adaptive Thresholding

mean

standard deviations

Niblack constant

T m k s

m

s

k

Niblack Algorithm

Neighborhood size???

Page 42: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

Document Binarization

• Local Thresholding – Examples

42

Original Niblack Sauvola

Wolf Feng NICK

Page 43: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

43

Image Morphology

Page 44: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

44

Introduction

Morphology

A branch of biology which deals with the form and

structure of animals and plants

Mathematical Morphology

A tool for extracting image components that are useful

in the representation and description of region shapes

The language of mathematical morphology is Set Theory

Page 45: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

45

Morphology: Quick Example

Image after segmentation Image after segmentation and

morphological processing

Page 46: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

46

Introduction

Morphological image processing describes a range of image processing

techniques that deal with the shape (or morphology) of objects in an image

Sets in mathematical morphology represents objects in an image. E.g. Set

of all white pixels in a binary image.

Page 47: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

47

Introduction

This represents a digital image. Each square is one pixel.

foreground:

I( ) cp0)I( p

background

Page 48: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

48

Set Theory

The set space of binary image is Z2

Each element of the set is a 2D vector whose

coordinates are the (x,y) of a black (or white,

depending on the convention) pixel in the image

The set space of gray level image is Z3

Each element of the set is a 3D vector: (x,y) and

intensity level.

NOTE:

Set Theory and Logical operations are covered in:

Section 9.1, Chapter # 9, 2nd Edition DIP by Gonzalez

Section 2.6.4, Chapter # 2, 3rd Edition DIP by Gonzalez

Page 49: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

49

Set Theory

Let A be a set in Z2. if a = (a1,a2) is an element of A,

then we write

If a is not an element of A, we write

Set representation

Empty or Null set

a A

a A

1 2 3 4{( , ),( , )}A a a a a

A

Page 50: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

50

Set Theory

Subset: if every element of A is also an element of

another set B, the A is said to be a subset of B

Union: The set of all elements belonging either to A, B or

both

Intersection: The set of all elements belonging to both A

and B

A B

C A B

D A B

Page 51: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

51

Set Theory

Two sets A and B are said to be disjoint or mutually

exclusive if they have no common element

Complement: The set of elements not contained in A

Difference of two sets A and B, denoted by A – B, is

defined as

i.e. the set of elements that belong to A, but not to B

A B

{ | }cA w w A

{ | , } cA B w w A w B A B

Page 52: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

52

Set Theory

Page 53: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

53

Set Theory

Reflection of set B

i.e. the set of element w, such that w

is formed by multiplying each of two

coordinates of all the elements of set

B by -1

{ | , for }B w w b b B

Page 54: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

54

Set Theory

Translation of set A by point z = (z1,z2), denoted (A)z, is

defined as

( ) { | , for }zA w w a z a A

Page 55: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

55

Structuring Element

A structuring element is a small image – used as a

moving window

Ex

amp

le S

tru

ctu

ring

Ele

men

ts

Str

uct

uri

ng E

lem

ents

con

ver

ted t

o

rect

ang

ula

r ar

rays

Page 56: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

56

Structuring Element

For simplicity we will use rectangular structuring

elements with their origin at the middle pixel

1 1 1

1 1 1

1 1 1

0 0 1 0 0

0 1 1 1 0

1 1 1 1 1

0 1 1 1 0

0 0 1 0 0

0 1 0

1 1 1

0 1 0

Page 57: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

57

Structuring Element: Reflection

( , ) , B x y B x y

rotated by 180º around its origin. is BB

1 B

2 B

3 B

1 B 2 B 3 B

Page 58: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

58

Structuring Element: Translation

Let I be an image and B

a SE.

(B)z means that B is

moved so that its origin

coincides with location z

in image I.

(B)z is the translate of B

to location z in I.

B

z=(z1,z2)

Page 59: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

59

Structuring Elements: Hits & Fits

B

AC

Structuring Element

Fit: All on pixels in the structuring element

cover on pixels in the image

Hit: Any on pixel in the structuring element

covers an on pixel in the image

All morphological processing operations are based on these simple ideas

Page 60: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

60

Fitting & Hitting

0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 1 1 0 0 0 0 0 0 0

0 0 1 1 1 1 1 0 0 0 0 0

0 1 1 1 1 1 1 1 0 0 0 0

0 1 1 1 1 1 1 1 0 0 0 0

0 0 1 1 1 1 1 1 0 0 0 0

0 0 1 1 1 1 1 1 1 0 0 0

0 0 1 1 1 1 1 1 1 1 1 0

0 0 0 0 0 1 1 1 1 1 1 0

0 0 0 0 0 0 0 0 0 0 0 0

B C

A

1 1 1

1 1 1

1 1 1

Structuring

Element 1

0 1 0

1 1 1

0 1 0

Structuring

Element 2

Page 61: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

61

Fundamental Operations

Fundamentally morphological image processing is very like spatial filtering

The structuring element is moved across every pixel in the original image to

give a pixel in a new processed image

The value of this new pixel depends on the operation performed

There are two basic morphological operations: erosion and dilation

Page 62: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

62

Erosion

Page 63: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

63

Erosion

The erosion of two sets A and B is defined as:

i.e. The Erosion of A by B is the set of all points z,

such that B, translated by z, is contained in A

{ | ( ) }zA B z B A !

Definition 1:

Page 64: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

64

Erosion

Definition 2:

Erosion of image f by structuring element s is given by

f s

The structuring element s is positioned with its origin at

(x, y) and the new pixel value is determined using the

rule:

otherwise 0

fits if 1),(

fsyxg

Page 65: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

65

Erosion – How to compute

For each foreground pixel (which we will call the input pixel)

Superimpose the structuring element on top of the input image so

that the origin of the structuring element coincides with the input pixel

position.

If for every pixel in the structuring element, the corresponding pixel in

the image underneath is a foreground pixel, then the input pixel is left

as it is.

If any of the corresponding pixels in the image are background,

however, the input pixel is also set to background value.

Page 66: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

66

Erosion – How to compute

Erosion with a structuring element of size 3x3

Page 67: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

Erosion

B

A

Page 68: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

Erosion

Page 69: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

69

Erosion: Example

Structuring Element

Original Image Processed Image With Eroded Pixels

Page 70: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

70

Erosion: Example

Structuring Element

Original Image Processed Image

Page 71: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

71

Erosion

Effects

Shrinks the size of foreground (1-valued) objects

Smoothes object boundaries

Removes small objects

Rule for Erosion

In a binary image, if any of the pixel (in the neighborhood defined by structuring element) is 0, then output is 0

Page 72: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

72

Erosion: Example 1

Original

image

After erosion

with a disc of

radius 10

After erosion

with a disc of

radius 20

After erosion

with a disc of

radius 5

Page 73: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

73

Erosion: Example 2

Page 74: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

74

Erosion: Example 3

Original image Erosion by 3*3

square structuring

element

Erosion by 5*5

square structuring

element

Note: In these examples a 1 refers to a black pixel!

Page 75: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

75

Erosion

Erosion can split apart joined objects

Erosion can strip away extrusions

Watch out: Erosion shrinks objects

Page 76: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

76

Exercise

Count the number of coins in the given image

Page 77: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

77

Exercise: Solution

Per

form

Ero

sion

Bin

ariz

e th

e im

age

Use connected component labeling to count the number of coins

Page 78: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

Readings from Book (3rd Edn.)

• Morphological Operations (Chapter – 9)

• Hough Transform (Chapter – 10)• Segmentation (Chapter – 10)• OTSU Algorithm (Chapter - 10)

Page 79: Lecture # 7 Hough Transform, Segmentation & Morphological ...biomisa.org/uploads/2014/09/Lect-7.pdf · 14 Hough Transform Implementation steps: • Initially the accumulator cells

79

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