Sei sulla pagina 1di 136

Morphological Image Processing

Counting coins example


Counting objects can be difficult when they touch each other.
Solution: Binarization and Erosion separates them.
Note that the coins become smaller – can be a problem if
structuring element causes object to disappear!

In Matlab, use the strel function to construct the structuring element, in


conjunction with imerode to perform the erosion process.
Erosion

Original image Eroded image


Erosion

Eroded once Eroded twice


Opening and Closing
 Opening : smoothes
A  the
B contour
( AB )ofanBobject, breaks narrow
isthmuses, and eliminates thin protrusions

 Closing : smooth sections of contours but, as opposed to


opning, it generally
A fuses
B narrow
( A  breaks
B )Band long thin gulfs,
eliminates small holes, and fills gaps in the contour

 Prove to yourself that they are not the same thing. Play around
with bwmorph in Matlab.
Opening and Closing
OPENING: The
original image
eroded twice and
dilated twice
(opened). Most
noise is removed

CLOSING: The
original image
dilated and then
eroded. Most
holes are filled.
Boundary Extraction
Dilation
Basic Concepts From Set
theory
Let A and B be sets.
To indicate a is an element of A write a  A.
To indicate a is not an element of A write a  A.
A is a subset of B, written A  B, if for every a  A, a  B.
The union of A and B, A  B   x | x  A or x  B.
The intersection of A and B, A  B   x | x  A and x  B.
The complement of A, A c   x | x  A.
The difference of A and B, A  B   x | x  A and x  B.
Examples

A B A B

A A A

B B B

Ac A  B  A  Bc

A A

B
The Cross Product

Let A and B be sets.


The cross - product of A and B, written A x B, is given by
A x B   (a, b) | a  A and b  B
Example
If Z represents the set of integers, then Z2   (z1 , z 2 ) | z1 , z 2  Z .
Focus on Half Tone images

• Morphological image processing assumes


objects that are represented in images using
only two “color” values say black and white.

• The coordinates of the black (or white) pixels


form a complete description of the objects in
the image.

• An object in a half-toned image is specified


completely as a subset A of Z2
Notation Specific To
Morphological Processing

Let A be a subset of Z 2 .
The reflection of A, written Â, is given by
   x | x  -a, where a  A.
Here, - a  -(a1 , a 2 )  (-a1 ,-a 2 )  A  Z 2 .
The translation of A by z, written (A)z , for some z  Z 2 is
(A)z   x | x  a  z , for a  A.
Special set operations
for morphology

translation reflection

( A) z  c c  a  z, for a  A Bˆ   w w  b, for b  B


Preliminaries

Bˆ  {w | w  b, for b  B}
( A) z  {c | c  a  z , for a  A}
Reflection and Translation
Bˆ   w w  b , for b  B
   
Reflection

Translation

   


 B z  c c  b  z, for b  B
Preview
 Morphology 形態學
 About the form and structure of animals and pl
ants
 Mathematical morphology
 Using set theory
 Extract image component
 Representation and description of region shape
Preview (cont.)
 Sets in mathematical morphology represent
objects in an image

 Example
 Binary image: the elements of a set is the
coordinate (x,y) of the pixels, in Z2
 Gray-level image: the element of a set is the
triple, (x, y, gray-value), in Z3
Outline

 Preliminaries – set theory


 Dilation and erosion
Binary
 Opening and closing
images  Hit-or-miss transformation
 Some basic morphological algorithms
 Extensions to gray-scale images
Preliminaries – set theory
 A be a set in Z2.

 a = (a1, a2) is an element of A. a A

 a is not an element of A a A

 Null (empty) set: 


Set theory (cont.)
Explicit expression of a set
1 A   a1 , a2 ,..., an 


2 A  element condition for set elements 
 Example:
C   w w  d , for d  D
Set operations
 A is a subset of B: every element of A is an element
of another set B A  B

 Union 聯集 C  A  B

 Intersection 交集 C  A  B

 Mutually exclusive A  B  
Graphical examples
Graphical examples (cont.)

A   w w  A
c
A  B   w w  A, w  B
Logic operations on binary
images
 Functionally complete operations
 AND, OR, NOT
A B

A B

BA
Special set operations
for morphology

translation reflection

( A) z  c c  a  z, for a  A Bˆ   w w  b, for b  B


Outline
 Preliminaries
 Dilation( 擴張 ) and erosion( 侵蝕 )
 Opening and closing
 Hit-or-miss transformation
 Some basic morphological algorithms
 Extensions to gray-scale images
dilation

 示例  
A  B  {z | Bˆ  A  }
z

The dilation of A by B is the set of all displacements, z, such that B̂ and A


overlap by at least one element.
 示例  
A  B  {z | Bˆ  A  }
z

B
A
 
A  B  {z | Bˆ  A  }
z

A B  B  A A  ( B  C )  ( A  B)  C
The dilation of A by B is the set of all displacements, z, such that B̂ and A
overlap by at least one element.
 示例  
A  B  {z | Bˆ  A  }
z 1 2 3 4 5
1 2 3 4 5
1
1 2
2
3
3 -1 0 1 1
4
4 1
0
5
0
5 -1
6
-1
6
7
7

A
B  
A  B  {z | Bˆ  A  }
z
The dilation of A by B is the set of all displacements, z, such that B̂ and A
overlap by at least one element.
 示例 AB  {z |  B  z  A} 2 3 4 5
1
1 2 3 4 5
1
1 2
2
3
3 4 1
1
4 0
0 5
5 -1
6
-1
6
7
7
B
A AB  {z |  B  z  A}
The erosion of A by B is the set of all points z such that B, translated

by z, is contained in A.
1-D Erosion example (5)

1 0 0 0 1 1 1 0 1 1

1 1 1
1-D Erosion example (5)

1 0 0 0 1 1 1 0 1 1

1 1 1

0 0 0 0 1
§ 8.2.2 腐蚀
erosion

 示例 AB  {z |  B  z  A}

The erosion of A by B is the set of all points z such that B, translated


by z, is contained in A.
Dilation Operations (cont.)
Reflection B̂

Structuring
Element (B)

Original image (A) Intersect pixel Center pixel


Dilation Operations (cont.)

Result of Dilation Boundary of the “center pixels”


 
where B̂ z intersects A
Example: Application of Dilation

“Repair” broken characters


(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Erosion Operation
A B   z  B  z  A

Erosion means “trim”

A = Object to be eroded
B = Structuring element

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Erosion Operations (cont.)

Structuring
Element (B)

Original image (A) Intersect pixel Center pixel


Erosion Operations (cont.)

Result of Erosion Boundary of the “center pixels”


where B is inside A
.

Dilation

B1
A
A  B1

B2

A  B2
42
B. Leibe Image Source: R.C. Gonzales & R.E. Woods
Dilation ( 擴張 )
B:structuring
element
A B   z ( Bˆ )  A   
z
Dilation: another formulation
A B   z ( Bˆ )  A  A
z
.

Dilation

B1
A
A  B1

B2

A  B2
45
B. Leibe Image Source: R.C. Gonzales & R.E. Woods
Structuring elements

By convention, we sometimes describe structuring


elements by showing only their 1s and their origin.

1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1

Three typical structuring elements. The origin is shown with a


black border.
0 0 0 1 0 0 0
0 0 1 1 1 0 0
0 1 1 1 1 1 0
1 1 1 1 1 1 1
0 1 1 1 1 1 0
0 0 1 1 1 0 0
0 0 0 1 0 0 0

Gốc của phần


tử cấu trúc
0 0 1 1 1 0 0
0 1 1 1 1 1 0
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
0 1 1 1 1 1 0
0 0 1 1 1 0 0

Gốc của phần


tử cấu trúc
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 1 1 1 1 0 0 0
0 0 0 1 1 1 1 0 0 0
0 0 0 1 1 1 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

1 1 1
1 1 1
1 1 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 1 1 1 1 0 0 0
0 0 0 1 1 1 1 0 0 0
1 1 1 0 0 0 1 1 1 1 0 0 0
1 1 1 0 0 0 0 0 0 0 0 0 0
1 1 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 1 1 1 1 1 1 0 0
0 0 1 1 1 1 1 1 0 0
0 0 1 1 1 1 1 1 0 0
0 0 1 1 1 1 1 1 0 0
0 0 1 1 1 1 1 1 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
Application of dilation:
bridging gaps in images
Effects: increase size, fill gap Structuring
element

max. gap=2 pixels


Counting coins example
Counting objects can be difficult when they touch each other.
Solution: Binarization and Erosion separates them.
Note that the coins become smaller – can be a problem if
structuring element causes object to disappear!

In Matlab, use the strel function to construct the structuring element, in


conjunction with imerode to perform the erosion process.
Erosion 侵蝕
A B   z ( B ) z  A
z: displacement

B:structuring
element
Erosion (cont.)
Ứng dụng phép mởi : Lọc nhiễu ;
test=zeros(10,10);test(2:6,2:4)=1;test(3:5,6:9)=1;test(8:9,4:8)=1;test(4,5)=1

0 0 0 0 0 0 0 0 0 0
0 1 1 1 0 0 0 0 0 0
sq =
0 1 1 1 0 1 1 1 1 0
1 1 1
0 1 1 1 1 1 1 1 1 0
1 1 1
0 1 1 1 0 1 1 1 1 0
1 1 1
0 1 1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 1 1 1 1 1 0 0
0 0 0 1 1 1 1 1 0 0
0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0
0 1 1 1 0 0 0 0 0 0
sq=ones(3,3) 0 1 1 1 0 1 1 1 1 0
imopen(test,sq) 0 1 1 1 0 1 1 1 1 0
0 1 1 1 0 1 1 1 1 0
0 1 1 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
Opening Operation
A  B  ( A B)  B
or
A  B   B  z  B  z  A
= Combination of all parts of A that can completely contain B

Opening eliminates narrow and small details and corners.


(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Example of Opening

(Images from Rafael C.


Gonzalez and Richard E.
Wood, Digital Image
Processing, 2nd Edition.
Closing Operation
A  B  (A  B) B

Closing fills narrow gaps and notches

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Example of Closing

(Images from Rafael C.


Gonzalez and Richard E.
Wood, Digital Image
Processing, 2nd Edition.
Duality Between Opening and Closing

 A  B c

 Ac  Bˆ 
Properties Opening
1. A  B  A
2. If C  D then C  B  D  B
3.  A  B  B  A  B
Properties Closing
1. A  A  B
2. If C  D then C  B  D  B
3.  A  B  B  A  B
Idem potent property: can’t change any more
A()B A()B  ( AX )   Ac (W  X ) 


A()B
A()B  ( AX )   Ac (W  X ) 
  AB1   Ac B2 

B   B1 B2 


(boundary extraction)

 ( A)  A  ( AB)

 
(boundary extraction)

 ( A)  A  ( AB)
 ( A)  A  ( AB )

 ( A)  ( A  B )  A ?
§ 边界提取
8.5.2 vs. 区域填充
区域填充
边界提取:给定区域 R 找边界。  ( A)  A  ( AB)
(Region filling)
区域填充:给定边界找区域 R 。 X k   X k 1  B   A 迭代 , 直到收敛 ; 最 R  X
c
K A

区域填充:设某区域的边界是 A, 设 p 是区域内的一点 ( 不在
边界上 ) 并设 X0=p, 选定一个结构元素 B 则边界 A 所构成的
区域 ( 点的集合 ) 可以通过如下迭代得到:
X 0  p; k  1

X k   X k 1  B   Ac

Xk==Xk-1?
(收敛?) false
true
R  XK A

Stop
X 1   X 0  B   Ac
(Region filling)
X 2   X 1  B   Ac
X 0  p; k  1
X 3   X 2  B   Ac
X k   X k 1  B   Ac
X 4   X 3  B   Ac
Xk==Xk-1?
X 5   X 4  B   Ac
(收敛?) false
true X 6   X 5  B   Ac
R  XK A
X 7   X 6  B   Ac
Stop
X 8   X 7  B   Ac
 X7

为什么最后要并 A R  X7 A
呢? R  X 7  A
§ 8.5.2 区域填充
(Region filling)

多个区域填充示例

X 0  p; k  1

X k   X k 1  B   Ac
Assumption: A point inside
Xk==Xk-1? each boundary is given
false
(收敛?)
true
R  XK A

Stop
Application of erosion:
eliminate irrelevant detail
Squares of size Erode with
1,3,5,7,9,15 pels 13x13 square

original image erosion dilation


Dilation and erosion are duals

( A B )   z ( B ) z  A
c c

  z ( B)  A   
z
c c

  z ( B)  A   
c

 
z
A  B  z ( Bˆ ) z  A  
 A  Bˆ
c
Application: Boundary extraction
 Extract boundary of a set A:
 First erode A (make A smaller)
 A – erode(A)

= A (A B)
Application: boundary
extraction
original image Using 5x5 structuring element
Outline
 Preliminaries
 Dilation and erosion
 Opening and closing
 Hit-or-miss transformation
 Some basic morphological algorithms
 Extensions to gray-scale images
Opening
 Dilation: expands image w.r.t structuring
elements
 Erosion: shrink image
 erosion+dilation = original image ?
 Opening= erosion + dilation
A B  (A B)  B
Opening (cont.)
Opening (cont.)

Find contour Fill in contour

Smooth the contour of an image, breaks narrow isthmuses,


eliminates thin protrusions 切除窄接線
消去小凸起
Closing
 Dilation+erosion = erosion + dilation ?
 Closing = dilation + erosion
A  B  ( A  B) B
Closing (cont.)

Find contour Fill in contour

Smooth the object contour, fuse narrow breaks and long


thin gulfs, eliminate small holes, and fill in gaps
連接小斷點,消除小空洞,填補空隙
Properties of opening and
closing
 Opening
(i) A  B is a subset (subimage) of A Open 後變小

(ii) If C is a subset of D, then C  B is a subset of D  B


(iii) ( A  B )  B  A  B 重複做 open 等於做一次 open
 Closing
(i) A is a subset (subimage) of A  B close 後變大

(ii) If C is a subset of D, then C  B is a subset of D  B


(iii) ( A  B )  B  A  B 重複做 close 等於做一次 close
Noisy
image

Remove
outer opening
noise
closing

Remove
inner
noise
Outline
 Preliminaries
 Dilation and erosion
 Opening and closing
 Hit-or-miss transformation
 Some basic morphological algorithms
 Extensions to gray-scale images
Matlab: Hit-or-miss transformation

A=[0 0 0000 0000 0 0 0 0 0 0;


001 0 0000 0000 0 0 0 0;
001 0 0011 1100 0 0 0 0;
011 1 0000 0000 1 1 0 0;
001 0 0100 0000 1 1 1 0;
000 0 1110 0000 0 1 0 0;
000 0 0100 0000 0 0 0 0;
000 0 0000 0000 0 0 0 0]

Ex6: Generate the right


images with structure
element
010
111
010
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 1 1 1 1 0 0 0 0 0 0
0 1 1 1 0 0 0 0 0 0 0 0 1 1 0 0
0 0 1 0 0 1 0 0 0 0 0 0 1 1 1 0
0 0 0 0 1 1 1 0 0 0 0 0 0 1 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

010
111
010
Hit-or-Miss transformation
The goal of the "hit-miss" operation is to find pixels x, for which B1x is in A
and where no pixel in B2x is in A (“miss”), thus B2x is in Ac.
The definition of the "hit-miss" operation is:
AB = { x  En | B1x   A  and  B2x   Ac}
It can be shown that:
AB = ( A   B1 )   ( Ac   B2 ) = ( A   B1 ) - ( A   B2r )

 Searching for white pixels, 


   that do not have 4-connected 
B1      neighboring pixels.

Original image Erosion with B1


(white pixels)

B2
Complement Erosion with B2
Boundary extraction
 (A) = A - (A  B)
B
Hit-or-miss transformation
 Find the location of certain shape
X

erosion

Find the set of pixels that


contain shape X
如何只找到相符形狀中心點?
Hit-or-miss transformation
Detect object via
background

Erosion
with (W-X)
Hit-or-miss transformation
 Eliminate un-necessary parts

AND
Hit-and-Miss Transform (IV)
 Guidelines for Use
 The hit-and-miss transform is used to look for
occurrences of particular binary patterns.
 It can be used to look for several patterns.
 Simply by running successive transforms using different
structuring elements, and then ORing the results together.
 The operations of erosion, dilation, opening, closing,
thinning and thickening can all be derived from the hit-
and-miss transform in conjunction with simple set
operations.
Hit-and-Miss Transform (V)
 Some structuring elements that can be used for locating various binary
features
 1) is used to locate isolated points in a binary image.
 2) is used to locate the end points on a binary skeleton.
 Note that this structuring element must be used in all its orientations, and
thus the four hit-and-miss passes are required.

Some applications of the hit-and-miss transform

3a) and 3b) are used to locate the triple points on a skeleton.
 Both structuring elements must be run in all orientations so
eight hit-and-miss passes are required.
Hit-and-Miss Transform (VI)
 The triple points (points where three lines meet) of the skeleton

 The hit-and-miss transform outputs single foreground pixels at each triple point by
structuring elements 3a) and 3b).
 This image was dilated once using a cross-shaped structuring element in

order to mark these isolated points clearly, and this was then ORed with the
original skeleton.
Hit-and-Miss Transform (VII)
 The end points of the skeleton

 The hit-and-miss transform outputs single foreground pixels at each end point by structuring element 2).
 This image was dilated once using a square-shaped structuring element, and this was then ORed with
the original skeleton.
Thinning (I)
 Brief Description
 Remove selected foreground pixels from binary
images, somewhat like erosion or opening.
 Thinning is normally applied only to binary
images.

Common names: Thinning


Outline
 Preliminaries
 Dilation and erosion
 Opening and closing
 Hit-or-miss transformation
 Some basic morphological algorithms
 Extensions to gray-scale images
Basic morphological algorithms
 Extract image components that are useful in the
representation and description of shape
 Boundary extraction
 Region filling
 Extract of connected components
 Convex hull
 Thinning
 Thickening
 Skeleton
 Pruning
Region filling
 How?
 Idea: place a point inside the region, then
dilate that point iteratively
X0  p
X k  ( X k 1  B )  Ac , k  1,2,3,...
Until X k  X k 1

Bound the growth


Region filling (cont.)

stop
Region Filling Algorithm

1. Pick a point inside p given it value 1


2. Set X0 = p
3. Start k = 1
4. Repeat getting Xk by

X k  ( X k 1  B)  A c
where k  1,2,3,...
5. Terminate process if Xk = Xk-1
6. The set union of Xk and A is answer
Region Filling Algorithm
Region Filling Algorithm

p
§ 边界提取
8.5.2 vs. 区域填充
区域填充
边界提取:给定区域 R 找边界。  ( A)  A  ( AB)
(Region filling)
区域填充:给定边界找区域 R 。 X k   X k 1  B   A 迭代 , 直到收敛 ; 最 R  X
c
K A

区域填充:设某区域的边界是 A, 设 p 是区域内的一点 ( 不在
边界上 ) 并设 X0=p, 选定一个结构元素 B 则边界 A 所构成的
区域 ( 点的集合 ) 可以通过如下迭代得到:
X 0  p; k  1

X k   X k 1  B   Ac

Xk==Xk-1?
(收敛?) false
true
R  XK A

Stop
§ 8.5.2 区域填充
单个区域填充示例 X 1   X 0  B   Ac
(Region filling)
X 2   X 1  B   Ac
X 0  p; k  1
X 3   X 2  B   Ac
X k   X k 1  B   Ac
X 4   X 3  B   Ac
Xk==Xk-1?
X 5   X 4  B   Ac
(收敛?) false
true X 6   X 5  B   Ac
R  XK A
X 7   X 6  B   Ac
Stop
X 8   X 7  B   Ac
 X7

为什么最后要并 A R  X7 A
呢? R  X 7  A
§ 边界提取
8.5.2 vs. 区域填充
区域填充
边界提取:给定区域 R 找边界。  ( A)  A  ( AB)
(Region filling)
区域填充:给定边界找区域 R 。 X k   X k 1  B   A 迭代 , 直到收敛 ; 最 R  X
c
K A

区域填充:设某区域的边界是 A, 设 p 是区域内的一点 ( 不在
边界上 ) 并设 X0=p, 选定一个结构元素 B 则边界 A 所构成的
区域 ( 点的集合 ) 可以通过如下迭代得到:
X 0  p; k  1

X k   X k 1  B   Ac

Xk==Xk-1?
(收敛?) false
true
R  XK A

Stop
§ 8.5.2 区域填充
单个区域填充示例 X 1   X 0  B   Ac
(Region filling)
X 2   X 1  B   Ac
X 0  p; k  1
X 3   X 2  B   Ac
X k   X k 1  B   Ac
X 4   X 3  B   Ac
Xk==Xk-1?
X 5   X 4  B   Ac
(收敛?) false
true X 6   X 5  B   Ac
R  XK A
X 7   X 6  B   Ac
Stop
X 8   X 7  B   Ac
 X7

为什么最后要并 A R  X7 A
呢? R  X 7  A
§ 8.5.2 区域填充
(Region filling)

多个区域填充示例

X 0  p; k  1

X k   X k 1  B   Ac
Assumption: A point inside
Xk==Xk-1? each boundary is given
false
(收敛?)
true
R  XK A

Stop
Application: region filling

The first filled


region
Original image Fill all regions
Extraction of connected
components
 找到連通部分
 Idea: start from a point in t
he connected component, a
nd dilate it iteratively

X0  p
X k  ( X k 1  B )  A, k  1,2,3,...
Until X k  X k 1
Extraction of connected
components (cont.)
original
雞肉

thresholding

erosion

去除小雜訊
(Extraction of connected components)

Region filling
Dilation Conditional dilation
 X  B   Ac
X B  X  B   condition 
Extraction of connected components
 X  B   ? 
§ 8.5.3 提取连通区域
(Extraction of connected components)

什么是连通区域呢?什么是连通区域的提取?提取连通区域
有什么用途呀?

原始图像: 6 个不同的连通区域 ( 物 Connected component labeling


体)
如何提取?
§ 8.5.3 提取连通区域
(Extraction of connected components)

设由集合 A 表示的连通区域为 Y. 如果已知 Y 上的一点


p, 则连通区域 Y 的所有元素可以如下的迭代公式求得:
X k   X k  B   A where X 0 =p, k  1, 2,3,...
流程图 示例
X 0  p; k  1

X k   X k 1  B   A

Xk==Xk-1?
(收敛?) false
true 流程图
Y  XK

Stop
§ 8.5.3 提取连通区域
(Extraction of connected components)

设由集合 A 表示的连通区域为 Y. 如果已知 Y 上的一点


p, 则连通区域 Y 的所有元素可以如下的迭代公式求得:
X k   X k  B   A where X 0 =p, k  1, 2,3,...
流程图 实际应用
X-ray image of chicken
X 0  p; k  1 filet with broken bone
fragments
X k   X k 1  B   A
Threshold image (binary)
Xk==Xk-1?
(收敛?) false
true X k   X k  B  A
Y  XK

Stop

Image erosed with a 5*5


structuring element
Skeletons 骨架

How to define a
Skeletons?
Set A Maximum disk
1. The largest disk
Centered at a pixel
2. Touch the boundary
of A at two or more
places

Recall: Balls of erosion!


Skeleton
 Idea: 不斷的 erosion

Erosion k 次
直到空集合
Problem
 The scanned image is not adjusted well

 How to detection the direction of lines?


 How to rotate?
Morphological Operators
 Basic idea
 Scan the image with a structuring element
 Perform set operations (intersection, union)
of image content with structuring element
 Two basic operations
 Dilation (Matlab: imdilate)
Matlab:
 Erosion (Matlab: imerode) >> help strel

 Several important combinations


 Opening (Matlab: imopen)
 Closing (Matlab: imclose)
 Boundary extraction 134
B. Leibe Image Source: R.C. Gonzales & R.E. Woods
.

Dilation
 Definition
The dilation of A by B is the set
ˆ of all displacements z, such that
( B) z and A overlap by at least one B1

element”. A
A  B1
ˆ
 ( ( B) z is the mirrored version of B,
shifted by z)
 Effects
 If current pixel z is foreground, set all
pixels under (B)z to foreground. B2
 Expand connected components
 Grow features
 Fill holes
A  B2
135
B. Leibe Image Source: R.C. Gonzales & R.E. Woods
Erosion
 Definition
 “The erosion of A by B is the set
of( B)
all displacements z, such that B1
z
is entirely contained in A”. A
1

 Effects
If not every pixel under (B)z is
foreground, set the current pixel z
to background. B2
 Erode connected components 2

 Shrink features
 Remove bridges, branches, noise

136
B. Leibe Image Source: R.C. Gonzales & R.E. Woods

Potrebbero piacerti anche