curs - operatii morfologice
TRANSCRIPT
-
8/9/2019 Curs - Operatii Morfologice
1/50
1
of
39Lecture 11
Digital Image Processing
Morphological Image Processing
Bibliography:
Dublin Institute of Technology, Image Processing – Morphology
Utah University, CS 4640: Image Processing Basics, Lecture 11
-
8/9/2019 Curs - Operatii Morfologice
2/50
2
of
39Contents
Once segmentation is complete,morphological operations can be used to
remove imperfections in the segmented
image and provide information on the formand structure of the image.
In this lecture we will consider:
– What is morphology?; – Simple morphological operations;
– Compound operations;
– Morphological algorithms.
-
8/9/2019 Curs - Operatii Morfologice
3/50
3
of
391, 0, Black, White?
Throughout all of the following slideswhether 0 and 1 refer to white or black is a
little interchangeable.
All of the discussion that followsassumes segmentation has already taken
place and that images are made up of 0s for
background pixels and 1s for object pixels. After this it doesn’t matter if 0 is black, white,
yellow, green…….
-
8/9/2019 Curs - Operatii Morfologice
4/50
4
of
39Pixel Neighborhoods
Remember the two definitions of “neighbors”that we’ve discussed:
4 Neighborhood 8 Neighborhood
-
8/9/2019 Curs - Operatii Morfologice
5/50
5
of
39What Is Morphology?
Morphological image processing (ormorphology ) describes a range of image
processing techniques that deal with the
shape (or morphology) of features in animage.
Morphological operations are typically
applied to remove imperfections introducedduring segmentation, and so typically
operate on bi-level images.
-
8/9/2019 Curs - Operatii Morfologice
6/50
6
of
39Quick Example
I m a g e s t a k e n f r o m G o n z a l e z & W o o d s ,
D i g i t a l I m a
g e P r o c e s s i n g ( 2 0 0 2 )
Image after segmentation Image after segmentation and
morphological processing
-
8/9/2019 Curs - Operatii Morfologice
7/50
7
of
39Structuring Elements, Hits & Fits
B
A
C
Structuring Element
Fit: All on pixels in the
structuring element coveron pixels in the image.
Hit: Any on pixel in the
structuring element coversan on pixel in the image.
All morphological processing operations are based
on these simple ideas.
-
8/9/2019 Curs - Operatii Morfologice
8/50
8
of
39Structuring Element
Definition: A struc tur ing element is simplya binary image (or mask) that allows us to
define arbitrary neighborhood structures.
Example:
This is the structuring element for the 4-
neighborhood.
-
8/9/2019 Curs - Operatii Morfologice
9/50
9
of
39Structuring Elements
Structuring elements can be any size and makeany shape.
However, for simplicity we will use rectangular
structuring elements with their origin at the middle
pixel (left: 8-neighborhood; center: 4-
neighborhood)
1 1 11 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 01 1 1
0 1 0
-
8/9/2019 Curs - Operatii Morfologice
10/50
10
of
39Fitting & 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 00 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
-
8/9/2019 Curs - Operatii Morfologice
11/50
11
of
39Fundamental Operations
Fundamentally morphological imageprocessing is very like spatial filtering.
The structuring element is moved across
every pixel in the original image to give apixel 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
-
8/9/2019 Curs - Operatii Morfologice
12/50
12
of
39Erosion
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 isdetermined using the rule:
otherwise0
fitsif 1
),(
f s
y x g
-
8/9/2019 Curs - Operatii Morfologice
13/50
13
of
39Erosion Example
Structuring Element
Original Image Processed Image With Eroded Pixels
-
8/9/2019 Curs - Operatii Morfologice
14/50
14
of
39Erosion Example
Structuring Element
Original Image Processed Image
-
8/9/2019 Curs - Operatii Morfologice
15/50
15
of
39Erosion Example 1
Watch out: In these examples a 1 refers to a black pixel!
Original image Erosion by 3*3
square structuring
element
Erosion by 5*5
square structuring
element
-
8/9/2019 Curs - Operatii Morfologice
16/50
16
of
39Erosion Example 2
Original
image
After erosion
with a disc of
radius 10
After erosionwith a disc of
radius 20
After erosion
with a disc of
radius 5
I m
a g e s t a k e n f r o m G o n z a l e z & W o o d s ,
D i g i t a l I m a
g e P r o c e s s i n g ( 2 0 0 2 )
-
8/9/2019 Curs - Operatii Morfologice
17/50
17
of
39What Is Erosion For?
Erosion can split apart joined objects
Erosion can strip away extrusions
Watch out: Erosion shrinks objects
Erosion can split apart
-
8/9/2019 Curs - Operatii Morfologice
18/50
18
of
39Dilation
Dilation of image f by structuring element s isgiven by f s.
The structuring element s is positioned with
its origin at (x, y) and the new pixel value isdetermined using the rule:
otherwise0
hitsif 1
),(
f s
y x g
-
8/9/2019 Curs - Operatii Morfologice
19/50
19
of
39Dilation Example
Structuring Element
Original Image Processed Image
-
8/9/2019 Curs - Operatii Morfologice
20/50
20
of
39Dilation Example
Structuring Element
Original Image Processed Image With Dilated Pixels
-
8/9/2019 Curs - Operatii Morfologice
21/50
21
of
39Dilation Example 1
Original image Dilation by 3*3
square structuring
element
Dilation by 5*5
square structuring
element
Watch out: In these examples a 1 refers to a black pixel!
-
8/9/2019 Curs - Operatii Morfologice
22/50
22
of
39Dilation Example 2
Structuring element
Original image After dilation
I m
a g e s t a k e n f r o m G o n z a l e z & W o o d s ,
D i g i t a l I m a
g e P r o c e s s i n g ( 2 0 0 2 )
-
8/9/2019 Curs - Operatii Morfologice
23/50
23
of
39What Is Dilation For?
Dilation can repair breaks
Dilation can repair intrusions
Watch out: Dilation enlarges objects
-
8/9/2019 Curs - Operatii Morfologice
24/50
24
of
39Compound Operations
More interesting morphological operationscan be performed by performing
combinations of erosions and dilations.
The most widely used of these compoundoperations are:
– Opening
– Closing
-
8/9/2019 Curs - Operatii Morfologice
25/50
25
of
39Opening
The opening of image f by structuringelement s, denoted f ○ s is simply an erosion
followed by a dilation
f ○ s = (f s) s
Original shape After erosion After dilation
(opening)
Note a disc shaped structuring element is used I m a g e s t a k e n f r o m G o n z a l e z & W o o d s ,
D i g i t a l I m a g e P r o c e s s i n g ( 2 0 0 2 )
-
8/9/2019 Curs - Operatii Morfologice
26/50
26
of
39Opening Example
Original
Image
Image
After
Opening
I m
a g e s t a k e n f r o m G o n z a
l e z & W o o d s ,
D i g i t a l I m a g e P r o c e s s i n g ( 2 0 0 2 )
-
8/9/2019 Curs - Operatii Morfologice
27/50
27
of
39Opening Example
Structuring Element
Original Image Processed Image
-
8/9/2019 Curs - Operatii Morfologice
28/50
28
of
39Opening Example
Structuring Element
Original Image Processed Image
-
8/9/2019 Curs - Operatii Morfologice
29/50
29
of
39Opening
Conclusions:• Opening operation is an erosion followed
by a dilation
• Stray foreground structures that aresmaller than the structuring element will
disappear.
• Larger structures will remain.
-
8/9/2019 Curs - Operatii Morfologice
30/50
30
of
39Closing
The closing of image f by structuringelement s, denoted f • s is simply a dilation
followed by an erosion
f • s = (f s) s
Original shape After dilation After erosion
(closing)
Note a disc shaped structuring element is used I m a g e s t a k e n f r o m G o n z a
l e z & W o o d s ,
D i g i t a l I m a g e P r o c e s s i n g ( 2 0 0 2 )
-
8/9/2019 Curs - Operatii Morfologice
31/50
31
of
39Closing Example
Original
Image
Image
After
Closing
I m
a g e s t a k e n f r o m G o n z a
l e z & W o o d s ,
D i g i t a l I m a g e P r o c e s s i n g ( 2 0 0 2 )
-
8/9/2019 Curs - Operatii Morfologice
32/50
32
of
39Closing Example
Structuring Element
Original Image Processed Image
33
-
8/9/2019 Curs - Operatii Morfologice
33/50
33
of
39Closing Example
Structuring Element
Original Image Processed Image
34
-
8/9/2019 Curs - Operatii Morfologice
34/50
34
of
39Closing
Conclusions:• Closing operation is a dilation followed by
an erosion.
• Holes in the foreground that are smallerthan the structuring element will be filled.
35
-
8/9/2019 Curs - Operatii Morfologice
35/50
35
of
39Opening and Closing Example
36
-
8/9/2019 Curs - Operatii Morfologice
36/50
36
of
39Opening and Closing Example
37
-
8/9/2019 Curs - Operatii Morfologice
37/50
37
of
39Opening and Closing Example
38
-
8/9/2019 Curs - Operatii Morfologice
38/50
38
of
39Morphological Processing Example
I m
a g e s t a k e n f r o m G o n z a
l e z & W o o d s ,
D i g i t a l I m a g e P r o c e s s i n g ( 2 0 0 2 )
39
-
8/9/2019 Curs - Operatii Morfologice
39/50
39
of
39Morphological Algorithms
Using the simple technique we have lookedat so far we can begin to consider some
more interesting morphological algorithms
We will look at: – Boundary extraction
– Region filling
There are lots of others as well though: – Extraction of connected components
– Thinning/thickening
– Skeletonisation
40
-
8/9/2019 Curs - Operatii Morfologice
40/50
40
of
39Boundary Extraction
Extracting the boundary (or outline) of anobject is often extremely useful.
1. The boundary can be given simply as
β (A) = A – (A B)
I m
a g e s t a k e n f r o m G o n z a
l e z & W o o d s ,
D i g i t a l I m a g e P r o c e s s i n g ( 2 0 0 2 )
41
-
8/9/2019 Curs - Operatii Morfologice
41/50
41
of
39Boundary Extraction Example
A simple image and the result of performingboundary extraction using a square 3*3
structuring element
Original Image Extracted Boundary I m a g e s t a k e n f r o m G o n z a
l e z & W o o d s ,
D i g i t a l I m a g e P r o c e s s i n g ( 2 0 0 2 )
42
-
8/9/2019 Curs - Operatii Morfologice
42/50
42
of
39Boundary Extraction (Outline)
2. Another method for boundary extraction
43
-
8/9/2019 Curs - Operatii Morfologice
43/50
43
of
39Boundary Extraction
44
-
8/9/2019 Curs - Operatii Morfologice
44/50
44
of
39Boundary Extraction Example
45
-
8/9/2019 Curs - Operatii Morfologice
45/50
45
of
39Region Filling
Given a pixel inside a boundary, regionfilling attempts to fill that boundary with
object pixels (1s)
I m
a g e s t a k e n f r o m G o n z a
l e z & W o o d s ,
D i g i t a l I m
a g e P r o c e s s i n g ( 2 0 0 2 )
Given a point inside
here, can we fill thewhole circle?
46
-
8/9/2019 Curs - Operatii Morfologice
46/50
46
of
39Region Filling (cont…)
The key equation for region filling is
where X0
is simply the starting point inside
the boundary, B is a simple structuring
element and Ac is the complement of A.
This equation is applied repeatedly until Xk
is equal to Xk-1.
Finally the result is unioned with the original
boundary. I m
a g e s t a k e n f r o m G o n z a
l e z & W o o d s ,
D i g i t a l I m
a g e P r o c e s s i n g ( 2 0 0 2 )
.....3,2,1 )( 1 k A B X X c
k k
47
-
8/9/2019 Curs - Operatii Morfologice
47/50
47
of
39Region Filling Step By Step
I m
a g e s t a k e n f r o m G o n z a
l e z & W o o d s ,
D i g i t a l I m
a g e P r o c e s s i n g ( 2 0 0 2 )
48
-
8/9/2019 Curs - Operatii Morfologice
48/50
48
of
39Region Filling Example
I m
a g e s t a k e n f r o m G o n z a
l e z & W o o d s ,
D i g i t a l I m
a g e P r o c e s s i n g ( 2 0 0 2 )
Original Image One RegionFilled
All RegionsFilled
49
-
8/9/2019 Curs - Operatii Morfologice
49/50
49
of
39Skeletonisation
50
-
8/9/2019 Curs - Operatii Morfologice
50/50
50
of
39Summary
The purpose of morphological processing isprimarily to remove imperfections added during
segmentation.
The basic operations are erosion and dilation.Using the basic operations we can perform
opening and closing.
More advanced morphological operation canthen be implemented using combinations of all
of these.