Post on 05-Apr-2018
transcript
7/31/2019 L3 Morphology
1/75
GV12/3072Image Processing.
1
Morphological Operations
7/31/2019 L3 Morphology
2/75
GV12/3072Image Processing.
2
Outline
Basic concepts: Erode and dilate
Open and close.
Granulometry
Hit and miss transform
Thinning and thickening
Skeletonization and the medial axis transform
Introduction to gray level morphology.
7/31/2019 L3 Morphology
3/75
GV12/3072Image Processing.
3
What Are Morphological
Operators? Local pixel transformations for processing
region shapes
Most often used on binary images
Logical transformations based on
comparison of pixel neighbourhoods with a
pattern.
7/31/2019 L3 Morphology
4/75
GV12/3072Image Processing.
4
Simple Operations - Examples
Eight-neighbour erode
a.k.a. Minkowsky subtraction
Erase any foreground pixel that has one
eight-connected neighbour that is
background.
7/31/2019 L3 Morphology
5/75
GV12/3072Image Processing.
5
8-neighbour erode
Erode 1 Erode 2 Erode 5
Threshold
7/31/2019 L3 Morphology
6/75
GV12/3072Image Processing.
6
8-neighbour dilate
Eight-neighbour dilate
a.k.a. Minkowsky addition
Paint any background pixel that has one
eight-connected neighbour that is foreground.
7/31/2019 L3 Morphology
7/75
GV12/3072Image Processing.
7
8-neighbour dilate
Dilate 1 Dilate 2 Dilate 5
7/31/2019 L3 Morphology
8/75
GV12/3072Image Processing.
8
Why?
Smooth region boundaries for shape
analysis.
Remove noise and artefacts from an
imperfect segmentation.
Match particular pixel configurations in an
image for simple object recognition.
7/31/2019 L3 Morphology
9/75
GV12/3072Image Processing.
9
Structuring Elements
Morphological operations take two
arguments:
A binary image
A structuring element.
Compare the structuring element to the
neighbourhood of each pixel. This determines the output of the
morphological operation.
7/31/2019 L3 Morphology
10/75
GV12/3072Image Processing.
10
Structuring elements
The structuring element is also a binary
array.
A structuring element has an origin.
1 1 1
1 1 1
1 1 1
0 1 0
1 1 1
0 1 0
0 1 0
1 0 1
0 1 0
1
1
0
7/31/2019 L3 Morphology
11/75
GV12/3072Image Processing.
11
Binary images as sets
We can think of the binary image and the
structuring element as sets containing the
pixels with value 1.
1 1 1
0 1 1
0 0 0
0
0
0
0
0
00 0 0 1 0
0 0 0 0 0
I= {(1,1), (2,1), (3,1),
(2,2), (3,2), (4,4)}
7/31/2019 L3 Morphology
12/75
GV12/3072Image Processing.
12
Some sets notation
Union and
intersection:
Complement
Difference
We use for the
empty set .
2121
2121
and:or:
IxIxxIIIxIxxII
IxxIC :
2121 and:\ IxIxxII
7/31/2019 L3 Morphology
13/75
GV12/3072Image Processing.
13
More sets notation
The symmetrical setofS with respect to
point o is
SxxoS :
1 1 1 1
1 1 1
0 1 1
0 0 0
0 0 0
1 1 0
1 1 1
0 1 1
1 1 1
1 1 1
1
1
1
0
1
1
1 1 1 1 1
0 1 1 1 0
0 1 1
1 1 11 1 1
1
11
0
11
1 1 1 1 1
0 1 1 1 0
7/31/2019 L3 Morphology
14/75
GV12/3072Image Processing.
14
Fitting, Hitting and Missing
S fitsIatx if
S hitsIatx if
S missesIatx if
ISssxyy },:{
ISssxyy },:{
ISssxyy },:{
7/31/2019 L3 Morphology
15/75
GV12/3072Image Processing.
15
Fitting, Hitting and Missing
0 1 0
1 0 1
0 1 1
1
1
1
1
1
0
1
1
0
1
1
0
1
1
0
0 1 0 0 0 0 1 00 1 0 1 0 1 0 0
0 1 1 1 1 0 0 0
0 1 1 1 0 0 0 0
0 1 0 0 0 0 0 0
0 1 0
1 1 10 1 0
Image Structuring
element
7/31/2019 L3 Morphology
16/75
GV12/3072Image Processing.
16
Erosion
The imageE=I S is the erosion of
imageIby structuring element S.
otherwise0
atfitsif1)(
xISxE
SsIsxxE everyfor:
7/31/2019 L3 Morphology
17/75
GV12/3072Image Processing.
17
Implementation (nave)% I is the input image, S is a structuring element
% with origin (ox, oy). E is the output image.
function E = erode(I, S, ox, oy)
[X,Y] = size(I);
[SX, SY] = size(S);
E = ones(X, Y);
for x=1:X; for y=1:Y
for i=1:SX; for j=1:SY
if(S(i,j))
E(x,y) = E(x,y) & ImageEntry(I, x+i-ox, y+j-oy);
end
end; end
end; end
7/31/2019 L3 Morphology
18/75
GV12/3072Image Processing.
18
Example
Structuring
element
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
7/31/2019 L3 Morphology
19/75
GV12/3072Image Processing.
19
Example
Structuring
element
0 1 1
1 1 1
1 1 1
1
1
1
0
1
1
1 1 1 1 1
0 1 1 1 0
7/31/2019 L3 Morphology
20/75
GV12/3072Image Processing.
20
Example
Structuring
element
1 0 0
0 1 0
0 0 1
0
0
0
0
0
0
0 0 0 1 0
0 0 0 0 1
7/31/2019 L3 Morphology
21/75
GV12/3072Image Processing.
21
Dilation
The imageD =I S is the dilation of
imageIby structuring element S.
otherwise0
athitsif1)(
xISxD
SsIysxxD and,:
7/31/2019 L3 Morphology
22/75
GV12/3072Image Processing.
23
Example
Structuring
element
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
7/31/2019 L3 Morphology
23/75
GV12/3072Image Processing.
24
Example
Structuring
element
0 1 1
1 1 1
1 1 1
1
1
1
0
1
1
1 1 1 1 1
0 1 1 1 0
7/31/2019 L3 Morphology
24/75
GV12/3072Image Processing.
25
Example
Structuring
element
1 0 0
0 1 0
0 0 1
0
0
0
0
0
0
0 0 0 1 0
0 0 0 0 1
7/31/2019 L3 Morphology
25/75
GV12/3072Image Processing.
26
Erosion and dilation
Erosion and dilation are dual operations:
Commutativity and associativity
SISI CC
)(
ISSI
ISSI
)()(
)()(
TSITSI
TSITSI
7/31/2019 L3 Morphology
26/75
GV12/3072Image Processing.
27
Opening and Closing
The opening ofIby S is
The closing ofIby S is
SSISI )(
SSISI )(
7/31/2019 L3 Morphology
27/75
GV12/3072Image Processing.
28
Opening and Closing
Opening and closing are dual
transformations:
Opening and closing are idempotent
operations:
SISI CC )(
SSISI
SSISI
)(
)(
7/31/2019 L3 Morphology
28/75
29
Example
Structuring
element
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
close
open
7/31/2019 L3 Morphology
29/75
30
Example
Structuring
element
0 1 1
1 1 1
1 1 1
1
1
1
0
1
1
1 1 1 1 1
0 1 1 1 0
close
open
7/31/2019 L3 Morphology
30/75
31
Example
Structuring
element
1 0 0
0 1 0
0 0 1
0
0
0
0
0
0
0 0 0 1 0
0 0 0 0 1
close
open
7/31/2019 L3 Morphology
31/75
GV12/3072Image Processing. 32
Morphological filtering
To remove holes in the foreground and islands inthe background, do both opening and closing.
The size and shape of the structuring elementdetermine which features survive.
In the absence of knowledge about the shape offeatures to remove, use a circular structuringelement.
7/31/2019 L3 Morphology
32/75
GV12/3072Image Processing. 33
Example
Structuring
element
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
Close then open
Open then close
7/31/2019 L3 Morphology
33/75
GV12/3072Image Processing. 34
Example
Structuring
element
0 1 1
1 1 1
1 1 1
1
1
1
0
1
1
1 1 1 1 1
0 1 1 1 0
Close then open
Open then close
7/31/2019 L3 Morphology
34/75
7/31/2019 L3 Morphology
35/75
GV12/3072Image Processing. 36
Count the Red Blood Cells
7/31/2019 L3 Morphology
36/75
GV12/3072Image Processing. 37
Granulometry
Provides a size distribution of distinct
regions or granules in the image.
We open the image with increasingstructuring element size and count the
number of regions after each operation.
Creates a morphological sieve.
7/31/2019 L3 Morphology
37/75
GV12/3072Image Processing. 38
Granulometryfunction gSpec = granulo(I, T, maxRad)
% Segment the image I
B = (I>T);
% Open the image at each structuring element size up to a
% maximum and count the remaining regions.
for x=1:maxRad
O = imopen(B,strel(disk,x));
numRegions(x) = max(max(connectedComponents(O)));
end
gSpec = diff(numRegions);
7/31/2019 L3 Morphology
38/75
GV12/3072Image Processing. 39
Count the Red Blood Cells
7/31/2019 L3 Morphology
39/75
GV12/3072Image Processing. 40
Threshold and Label
7/31/2019 L3 Morphology
40/75
GV12/3072Image Processing. 41
Disc(11)
7/31/2019 L3 Morphology
41/75
GV12/3072Image Processing. 42
Disc(19)
7/31/2019 L3 Morphology
42/75
GV12/3072Image Processing. 43
Disc(59)
7/31/2019 L3 Morphology
43/75
GV12/3072
Image Processing.
44
Number of Regions
Struct. Elt. radius
Numberofregions
7/31/2019 L3 Morphology
44/75
GV12/3072
Image Processing.
45
Granulometric Pattern
Spectrum
Numberofregions
Struct. Elt. radius
7/31/2019 L3 Morphology
45/75
GV12/3072
Image Processing.
46
Hit-and-miss transform
Searches for an exact match of the
structuring element.
H = I S is the hit-and-miss transform of
imageIby structuring element S.
Simple form of template matching.
7/31/2019 L3 Morphology
46/75
GV12/3072
Image Processing.
47
Hit-and-miss transform1 0 1
1 1 0
1 0 0
1
1
1
1
0
1
1 1 0 1 1
1 0 1 0 1
1 0 1 =
0 1 0
0 0 1
0 0 0
0
0
0
0
0
0
0 0 1 0 0
0 1 0 1 0
1 0 1
1 1 0
1 0 0
1
1
1
1
0
1
1 1 0 1 1
1 0 1 0 1
* 1 =
0 1 0
0 0 0
0 1 0
0
0
0
0
1
0
0 0 1 0 0
0 0 0 0 0
1 0
7/31/2019 L3 Morphology
47/75
Upper-Right Corner Detector
GV12/3072
Image Processing.
48
7/31/2019 L3 Morphology
48/75
GV12/3072
Image Processing.
49
Thinning and Thickening
Defined in terms of the hit-and-miss
transform:
The thinning ofIby S is
The thickening ofIby S is
Dual operations:
)(\ SIISI
)( SIISI
SISI CC )(
7/31/2019 L3 Morphology
49/75
GV12/3072
Image Processing.
50
Sequential
Thinning/Thickening These operations are often performed in
sequence with a selection of structuring
elements S1, S2, , Sn. Sequential thinning:
Sequential thickening:
))...)(((,...,1: 21 ni SSSIniSI
))...)(((,...,1: 21 ni SSSIniSI
7/31/2019 L3 Morphology
50/75
GV12/3072
Image Processing.
51
Sequential
Thinning/Thickening Several sequences of structuring elements
are useful in practice
These are usually the set of rotations of asingle structuring element.
Sometimes called the Golay alphabet.
7/31/2019 L3 Morphology
51/75
GV12/3072
Image Processing.
52
Golay element L
0 0 *
0 1 1
* 1 *
L8
0 * 1
0 1 1
0 * 1
L7
* 1 *
0 1 1
0 0 *
L6
1 1 1
* 1 *
0 0 0
L5
* 1 *
1 1 0
* 0 0
L4
1 * 0
1 1 0
1 * 0
L3
* 0 0
1 1 0
* 1 *
L2
0 0 0
* 1 *
1 1 1
L1
7/31/2019 L3 Morphology
52/75
GV12/3072
Image Processing.
53
Sequential Thinning
See bwmorph in matlab.
0 iterations 1 iteration 2 iterations 5 iterations Inf iterations
7/31/2019 L3 Morphology
53/75
GV12/3072
Image Processing.
54
Sequential Thickening
2 iterations
1 iteration
Inf
iterations
5 iterations
7/31/2019 L3 Morphology
54/75
GV12/3072
Image Processing.
55
Skeletonization and the Medial
Axis Transform The skeleton and medial axis transform
(MAT) are stick-figure representations of a
regionX 2
.
Start a grassfire at the boundary of theregion.
The skeleton is the set of points at whichtwo fire fronts meet.
7/31/2019 L3 Morphology
55/75
GV12/3072
Image Processing.
56
Skeletons
7/31/2019 L3 Morphology
56/75
GV12/3072
Image Processing.
57
Medial axis transform
Alternative skeleton definition: The skeleton is the union of centres of maximal
discs withinX.
A maximal disc is a circular subset ofXthat touches
the boundary in at least two places.
The MAT is the skeleton with the maximal
disc radius retained at each point.
7/31/2019 L3 Morphology
57/75
GV12/3072
Image Processing.
58
Medial axis transform
7/31/2019 L3 Morphology
58/75
GV12/3072
Image Processing.
59
Skeletonization using
morphology Use structuring element
The n-th skeleton subset is
The skeleton is the union of
all the skeleton subsets:
1
)()(n
n XSXS
0 1 0
1 1 1
0 1 0
B =
BBXBXXS nnn )(\)()( n denotes n
successive
erosions.
7/31/2019 L3 Morphology
59/75
GV12/3072
Image Processing.
61
Reconstruction
We can reconstruct regionXfrom its
skeleton subsets:
We can reconstructXfrom the MAT.
We cannot reconstructXfrom S(X).
0
)(n
nn BXSX
7/31/2019 L3 Morphology
60/75
GV12/3072
Image Processing.
62
DiFi: Fast 3D Distance Field Computation Using Graphics Hardware
Sud, Otaduy, Manocha, Eurographics 2004
7/31/2019 L3 Morphology
61/75
MAT in 3D
GV12/3072
Image Processing.
63
from Transcendata Europe Medial Object
Price, Stops, Butlin Transcendata Europe Ltd
7/31/2019 L3 Morphology
62/75
GV12/3072
Image Processing.
64
Applications and Problems
The skeleton/MAT provides a stick figure
representing the region shape
Used in object recognition, in particular, characterrecognition.
Problems: Definition of a maximal disc is poorly defined on a digital grid.
Sensitive to noise on the boundary.
Sequential thinning output sometimes preferred to
skeleton/MAT.
7/31/2019 L3 Morphology
63/75
GV12/3072
Image Processing.
65
Example
Skeletons:
Thinned:
7/31/2019 L3 Morphology
64/75
GV12/3072
Image Processing.
66
Gray-level Morphology
Erosion, dilation
Opening and closing
The image and the structuring element aregray level arrays.
Used to remove speckle noise. Also for smoothing, edge detection and
segmentation.
7/31/2019 L3 Morphology
65/75
GV12/3072
Image Processing.
67
Umbra
f U(f)
)(:),()( xfyyxfU
7/31/2019 L3 Morphology
66/75
GV12/3072
Image Processing.
68
Top surface
T(R)R
RzxzyyxRT ),(allfor:),()(
7/31/2019 L3 Morphology
67/75
GV12/3072
Image Processing.
69
Gray level erode and dilate
Erosion:
Dilation:
Open and close defined as before.
))()(( kUfUTkf
))()(( kUfUTkf
7/31/2019 L3 Morphology
68/75
GV12/3072
Image Processing.
70
f U(f)
k
))()(( kUfUT )()( kUfU
)(kU
7/31/2019 L3 Morphology
69/75
GV12/3072
Image Processing.
72
Erosion
S=ones(3,3) S=ones(5,5) S=ones(7,7)
7/31/2019 L3 Morphology
70/75
GV12/3072
Image Processing.
73
Dilation
S=ones(3,3) S=ones(5,5) S=ones(7,7)
7/31/2019 L3 Morphology
71/75
GV12/3072
Image Processing.
74
Speckle removal
Salt and pepper noise
Dilate
Erode
Close
Open
7/31/2019 L3 Morphology
72/75
Favorites
E = medfilt2()
[D,L] = bwdist()
GV12/3072
Image Processing.
75
7/31/2019 L3 Morphology
73/75
GV12/3072
Image Processing.
76
Summary
Simple morphological operations Erode and dilate
Open and close Applications:
Granulometry
Thinning and thickening
Skeletons and the medial axis transform
Gray level morphology
7/31/2019 L3 Morphology
74/75
GV12/3072
Image Processing.
77
7/31/2019 L3 Morphology
75/75
Find the Letter e