240-373: Chapter 6: Morphological Image 1 Montri Karnjanade cha [email protected] .th http://fivedots.c oe.psu.ac.th/~mon tri 240-373 Image Processing
Jan 02, 2016
240-373: Chapter 6: Morphological Image
Processing
1
Montri [email protected]://fivedots.coe.psu.ac.th/~montri
240-373 Image Processing
240-373: Chapter 6: Morphological Image
Processing
3
Morphological and Other Area Operations
• Introduction– Morphology is the science of form and structure– It is about regions or shapes, in computer vision
• Morphology can be used for the following tasks:– Smoothing the edges of a region– Forcing shapes onto region edges– Counting regions– Estimating sizes of regions
240-373: Chapter 6: Morphological Image
Processing
4
Morphological Operations
• Morphological operations are easily seen on bin ary images but they can be extended to work o
- n gray level images• Basic Morphological Operations
– Consider the following image 1 * 1 * 1
* 1 * 1 *
1 * 1 * 1
– This could be represented as a set of those pixels in 5 x 3 image that have value ‘1’, namely
00 02 04 11 13 20{( , ), ( , ), ( , ), ( , ), ( , ), ( , ), 22 24
240-373: Chapter 6: Morphological Image
Processing
5
Morphological Operations
• And now it is possible to do set operations on images
1 * 1 * 1 * * * 1 1
A * 1 * 1 *= B 1** * 1 1
1 * 1 * 1 * * * 1 1
Giving
1 * 1 1 1 **** 1
A union B 1 1 *1 * 1 1 A intersection B 1 ***1
*
1 * 1 1 1 **** 1
240-373: Chapter 6: Morphological Image
Processing
6
Morphological Operations
• The set on unknown pixels (*) can, theoretically, extend infinitely
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 1 * 1 * 1 * * * * * * * * * * * 1 * 1 * * * * * *
* * * * * 1 * 1 * 1 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
where the circle around the top left 1 indicates the position of the origin
240-373: Chapter 6: Morphological Image
Processing
7
Dilation
1Technique : Dilation (Minkowski addition)
USE: Region edge valley filling (for binary image)
OPERATION:– A template (made from 1’s and *’s) is create
d with a known origin– The origin of this template is stepped over ev
ery element in the whole of the image
240-373: Chapter 6: Morphological Image
Processing
8
Dilation
OPERATION: (cont’d)
– The template is ‘unioned’ where the origin of the template corresponds to a 1 in the image
– - The resulting template sized matrix is then u - nioned with all other template sized results (
using their original position)
240-373: Chapter 6: Morphological Image
Processing
9
Dilation Example
Image Template
Applying the template to the first line gives
1111111****
1111111****
1*11111****
1111111****
*11*11*****
1***1******
*1**1******
11
*1
11*11******
*1**1******
240-373: Chapter 6: Morphological Image
Processing
10
Dilation Example
Application across the whole image gives new
row
new column– Continually applying this to the images fills out all the
holes and makes the image grow, one row and one column at a time
11111111****
11111111****
11111111****
11111111****
11111111****
1111111*****
*11*11******
**1**1******
240-373: Chapter 6: Morphological Image
Processing
11
Erosion
2:Technique Erosion (Minkowski subtraction)
USE: To remove spikes from the edges of regions
OPERATION:– A template is created– The template is stepped over the image but it is not al
lowed to go outside the image– For every position, if the template is the same as the i
mage window, then the element corresponding to the originof t he t empl at e i s set t o a 1
240-373: Chapter 6: Morphological Image
Processing
12
Erosion Example
1111111****
1111111****
1*11111****
1111111****
*11*11*****
1***1******
*1**1******
11
*1
Image Template
240-373: Chapter 6: Morphological Image
Processing
13
Erosion Example
• Final result is
unused row and column
***********
**1********
***********
*1**1******
***********
***********
***********
240-373: Chapter 6: Morphological Image
Processing
14
Gray-level Erosion and Dilation
Technique 3: Gray-level erosion and dilation
USE: Flattening spikes and filling valleys on region edges in gray-level images
OPERATION: – Let I(x,y) be an image of gray levels and
R(x,y) be resulting image after I(x,y) has been dilated/eroded with m x n template T(i,j)
0 <= i <= m-1, 0 <= j <= n-1
240-373: Chapter 6: Morphological Image
Processing
15
Gray-level Erosion and Dilation
OPERATION: – Gray level dilation is defined as
– and gray level erosion is
),(),(),( max1010
jiTjyixIyxR
njmi
),(),(),( min1010
jiTjyixIyxR
njmi
240-373: Chapter 6: Morphological Image
Processing
16
Gray-level Erosion and Dilation
NOTES: – For both of the above definitions, I(x,y) = 0
for locations outside of an M x N image– Dilation is precisely the dual of the erosion
operation. A dilation can be performed by reflecting the template and negating the original image and then negating the result.
240-373: Chapter 6: Morphological Image
Processing
17
Example
Consider the following initial image
Dilating by the template
00000000
00244200
00488400
00244200
00000000
11
11
240-373: Chapter 6: Morphological Image
Processing
18
Example
gives
or subtracting 1 throughout
11111111
13555311
11599511
11599511
13555311
11111111
00000000
02444200
00488400
00488400
02444200
00000000
240-373: Chapter 6: Morphological Image
Processing
19
Example
Conversely, erode by the same template gives
11111111
11111111
11113111
11113111
11111111
240-373: Chapter 6: Morphological Image
Processing
20
Example
or if 1 is subtracted throughout
00000000
00000000
00024200
00024200
00000000
240-373: Chapter 6: Morphological Image
Processing
21
Example
NOTE:– Dilationgi ves a l ar ger i mage, whi l e er osi on gi ves a smal l
er i mage– Inbot h cases, t he or i gi nal st r uct ur e of t he i mage i
s mai nt ai ned– If the template is not constant, say
10
01
240-373: Chapter 6: Morphological Image
Processing
22
Example
the results are as follows:
- 1 1Original Dilate Erode +
• D(E(D(I))) = D(I) and E(D(E(I))) = E(I)
00000000
00244200
00488400
00244200
00000000
02443100
04887300
03788400
01344200
00000000
00000000
00000000
00024300
00034200
00000000
240-373: Chapter 6: Morphological Image
Processing
23
Opening and Closing Operations
• OPENING = dilating after eroding• CLOSING = eroding after dilating
4:Technique Opening and closing operations
USE: As a step towards the skeleton, count - ing, and size estimating operations belo
w
240-373: Chapter 6: Morphological Image
Processing
24
Opening and Closing Operations
OPERATION:– Let OPEN(I,T ) be the opening of image I by so
me template T– Then using previous terminology and the te
mplate T throughoutOPEN( I,T) = D(E(I))
This gives
240-373: Chapter 6: Morphological Image
Processing
25
Opening and Closing Operations
Original Opened with Opened with
Clearly, this restores the image to its original and avoids the scaling of the result. It introduces the shaping of the template into the original.
00000000
00244200
00488400
00244200
00000000
00000000
00244200
00244200
00244200
00000000
00000000
00244200
00344200
00234200
0000000011
1111
01
240-373: Chapter 6: Morphological Image
Processing
26
More interesting is its operation on clear edges Original Opened with
Note how the peak (1 1 2 5 5 4) has been smoothed to the shape of the template but that the trough (1 3) has been left alone.
32100000
32100000
31000000
32100000
44210000
44210000
41000000
00000000
32210000
32100000
31000000
32100000
45521100
54210000
41000000
00000000
1
1
240-373: Chapter 6: Morphological Image
Processing
27
Closing is defined asCLOSE(I,T’) = E(D(I))
with E and D using T’ where T’ is the 180o rotation of T
Original Closed with
Now the trough has been filled but the peak has been left.
32210000
32100000
32100000
32100000
45521100
54210000
41000000
00000000
32210000
32100000
31000000
32100000
45521100
54210000
41000000
00000000
1
1
240-373: Chapter 6: Morphological Image
Processing
28
Properties of open and close operations
• OPEN -> forces the shape of the template on the convex parts of an edge
• CLOSE -> forces its shape on the concave parts of an edge
• These two operations can be combined to produce a skeleton operation
240-373: Chapter 6: Morphological Image
Processing
29
Skeleton Operations
5:Technique Skeleton operations
USE: To create a skeleton of a region. This will consist of a set of lines correspondin
g to complete thinning of the region with out losing the essential shape.
240-373: Chapter 6: Morphological Image
Processing
30
Skeleton Operations
OPERATION:– Let D
1 , D2
, …, Dn be structuring templates t hat are square, with sizes 1x1, 2x2, …, n x n ,
all of them filled with 1’s.
– Wi t h i mage I , using template D1
, D2
, …, Dn , i n turn, evaluate
resulti = - E(I) OPEN(E(I))
– Then determine
)result()(SK max allfor
ii
I
240-373: Chapter 6: Morphological Image
Processing
31
Skeleton Operations
Example: Original Final
image
using only D1, D2, D3, and D4
• This corresponds to a skeleton of the image, retaining length but reduce thickness
000000000
000000000
002100000
001000000
001000000
001000000
003110000
001000000
000000000
32210000
32100000
31000000
32100000
45521100
54210000
41000000
00000000
240-373: Chapter 6: Morphological Image
Processing
32
Granule sizing and granule counting
Technique 6: Granule sizing and granule counting
USE: To estimate the number of bright regions in an image. To estimate the size of the regions in an image.
240-373: Chapter 6: Morphological Image
Processing
33
Granule sizing and granule counting
OPERATION:– Using templates such as a set of vertical or horizontal
1 ’s with increasing length to estimate the size of the area
– Usingver t i cal or hor i zont al t empl at es wi t h bi nar y st r i 2ngshavi ng val ues n +1(i.e. 1, 11, 101, 1001, 10001, etc.) t o count111 111 111 11 11111
– Inbothcases, t he i mage i s er oded by t he st r uct ur i ng t emp lates and a measure of how many elements are now non
- 11 1 111 11 111 111 11 11 111 111111 11 1111111111,– 111 111111 11 1111111 1111111 111 11111111 111111111 111111 11
give a covariance curve whose peaks indicate the size a nd number of granules (areas) in the image.
240-373: Chapter 6: Morphological Image
Processing
34
Example
• The following image was eroded with the templates as shown below. After each erosion the number of pixels > 0 was counted and the power of the resulting image was summed.
Original image
0000000000
0000040000
1000022000
6500034410
3650021100
4400003200
240-373: Chapter 6: Morphological Image
Processing
35
Example
Length Type
of string 11….1 10…01
power count powercount
1 63 20 63 202 31 11 31 113 8 4 8 44 1 1 2 25 0 0 3 36 7 77 7 78 4 49 1 110 0
0
240-373: Chapter 6: Morphological Image
Processing
36
Example
Given a slightly altered image
0000000000
2334222400
1220222000
6500034410
3650021100
4400003200