Digital Image Processing - Sharif University of...
Transcript of Digital Image Processing - Sharif University of...
Digital Image Processing
MORPHOLOGICAL
Hamid R. Rabiee
Fall 2015
Image Analysis
Morphological Image Processing
Edge Detection
Keypoint Detection
Image Feature Extraction
Texture Image Analysis
Shape Analysis
Color Image Processing
Template Matching
Image Segmentation
2
Image Analysis 3
Figure 9.1 of Jain book
Image Analysis
Ultimate aim of image processing applications:
Automatic description, interpretation, or understanding the scene
For example, an image understanding system should be able to send the report:
The field of view contains a dirt road surrounded by grass.
4
Image Analysis 5
Table 9.1 of Jain book
Image Analysis 6
Morphological Analysis Edge Detection Keypoint Detection
original binary
erosion dilation
opening closing
Morphological Image Processing
(MIP)
7
Outline
Preview
Preliminaries
Dilation
Erosion
Opening
Closing
Hit-or-miss transformation
8
Outline (cont.)
Morphological algorithms
Boundary Extraction
Hole filling
Extraction of connected components
Convex hall
Thinning
Thickening
Skeleton
9
Outline (cont.)
Gray-scale morphology
Dilation and erosion
Opening and closing
Rank filter, median filter, and majority filter
10
Preview
Mathematical morphology
a tool for extracting image components that are useful in the representation and
description of region shape, such as boundaries, skeletons, and convex hull
Can be used to extract attributes and “meaning” from images, unlike pervious
image processing tools which their input and output were images.
Morphological techniques such as morphological filtering, thinning, and
pruning can be used for pre- or post-processing
All the concepts are introduced on binary images. Some extensions to gray-
scale images are discussed later.
11
Preliminaries
The language of mathematical morphology is set theory:
In binary images, the sets in question are members of the 2-D integer space 𝒁𝟐,
where each element of a set is a 2-D vector whose coordinates are the (x, y)
coordinates of a white pixel (by convention) in the image
12
White pixels of the image represent foreground (1 pixels)
Black pixels of the image are background (0 pixels)
binary images
background
foreground
Preliminaries
In addition to basic set operations including union, intersection,
complement, and difference, we will need:
Translation:
Reflection:
13
Preliminaries
Operations in morphological image processing are shift-invariant
Each operation needs a structuring element (SE)
SE is a binary image, which it’s origin must be specified
Some examples are cross, square, and circle SEs
14
cross square circle
Dilation
The dilation of set A by structuring element B, is defined as
15
Figure 9.6 of Gonzalez book
Dilation
Expands the size of foreground objects
Smooths object boundaries
Closes holes and gaps
16
Original image Dilation with 3 * 3 cross SE Dilation with 7 * 7 cross SE
Original image is taken from MIT course slides
Dilation
Using dilation to fix a text image with broken characters
17
Original image Dilation with 3 * 3 cross SE Dilation with 5 * 5 cross SE
Original image is taken from figure 9.7 of Gonzalez book
Dilation
Dilation is commutative
Dilation is associative
Note: can be decomposed to structuring elements and
This decomposition can cause speed-up
18
Erosion
The erosion of set A by structuring element B, is defined as
19
Figure 9.4 of Gonzalez book
Erosion
Shrinks the size of foreground objects
Smooths object boundaries
Removes peninsulas, fingers and small objects
20
Original image Erosion with 3 * 3 cross SE Erosion with 7 * 7 cross SE
Original image is taken from MIT course slides
Erosion
Using erosion to clear the thin wires in an image
21
Original image Erosion with a disk of radius 10 Erosion with a disk of radius 20Erosion with a disk of radius 5
Original image is taken from figure 9.5 of Gonzalez book
Relationship between dilation and erosion
Duality: Dilation and erosion are duals of each other with respect to set
complementation and reflection
Proof
22
and
The opening of set A by structuring element B, is defined as
The geometric interpretation of opening
23Opening
Figure 9.8 of Gonzalez book
The closing of set A by structuring element B, is defined as
The geometric interpretation of closing is based on opening using
duality property
24Closing
Figure 9.9 of Gonzalez book
Duality: Opening and closing are duals of each other with respect to set
complementation and reflection
Proof: homework
25Relationship between opening and closing
and
26Open filter & close filterOriginal image
Result of opening
Result of openingfollowed by closing
: 3 * 3 square SE
Figure 9.11 of Gonzalez book
The hit-or-miss transformation of by ,where is a structuring element
pair is defined as
Suppose that is enclosed by a small window . The local background
of with respect to is defined as the set difference , and the
structuring element B2 is as follows
27Hit-or-miss transformation
example
–
28Hit-or-miss transformationOriginal image
Structuring
element B1Structuring
element B2
( to be more visible)
Morphological algorithms
Boundary Extraction
Hole filling
Extraction of connected components
Convex hall
Thinning
Thickening
Skeleton
Pruning
29
The boundary of set can be obtained using erosion
Also the we can use dilation to obtain boundary
The difference between dilation and erosion results thicker boundary
30Boundary extraction
31Boundary extraction
Original image
Original image is taken from MIT course slides
32Hole filling
Hole: background region surrounded by a
connected border of foreground pixels
Assumption: a point inside each hole
region is given, , and is symmetric
In each iteration
Termination is at iteration step if
The set union of and contains all filled
holes and their boundaries
Figure is taken from Gonzalez book
33Extraction of connected components
Connected component: refer to definition!
Assumption: a point on one of the connected
components of set is given and .
The objective is to find all the elements of this
connected component.
In each iteration:
Termination is at iteration step if
is the set containing all the elements of the
connected component.
Figure is taken from Gonzalez book
34Convex hall
The convex hall of an arbitrary set is the smallest convex set containing .. .
Assumption: represent four structuring elements.
In each iteration: : hit-or-miss transformation
Termination is at iteration step if and we define
Then convex hall of is
Limiting growth of convex hall algorithm along the vertical and horizontal
directions
35Convex hall
Limiting growth of convex hall algorithm
Figure is taken from Gonzalez book
The thinning of a set by a structuring element is defined in terms of hit-or-
miss transformation
To thin symmetrically a sequence of structuring elements is used
Where is a rotated version of
Definition of thinning by a set of structuring elements
36Thinning
37Thinning
Figure is taken from Gonzalez book
Thickening is the morphological dual of thinning and is defined as
Definition of thickening by a set of structuring elements
Usual procedure in practice
Thin the background of a set in question and then complement the result.
Afterwards remove the resulting disconnected points.
The thinned background forms a boundary for the thickening process which is one
of the principal reasons for using this procedure.
38Thickening
39Thickening
Result of Thinning of Remove disconnected points
Final result of Thickening of
Figure is taken from Gonzalez book
First we define
The skeleton of set A is
can be reconstructed using
The resulting set may be disconnected
Other algorithms are needed if the skeleton must be maximally thin, connected
and minimally eroded
40Skeleton
41Skeleton
Original set
Morphological skeleton
Reconstructed set
Figure is taken from Gonzalez book
The basic operations introduced for binary images are extendable to gray-
scale images
In this case f(x, y) is a gray-scale image and b(x, y) is a structuring element
Structuring elements in gray-scale morphology belong to one of two
categories: non-flat and flat
Gray-scale SEs are used infrequently in practice
42Gray-scale morphology
The dilation with flat structuring element is defined as
The erosion with flat structuring element is defined as
The dilation with non-flat structuring element is defined as
The erosion with non-flat structuring element is defined as
43Dilation and erosion
44Dilation and erosion
Example:
Flat SE
Original image Dilation with 5 * 5 square SE Erosion with 5 * 5square SE
Width of lines is not preserved
As in the binary case, dilation and erosion are duals with respect to function
complementation and reflection
Where
Simplifying the notation
Similarly
45Dilation and erosion
and
The expressions for Opening and closing gray-scale images have the
same form as their binary counterparts.
Opening
Closing
Duality of opening and closing
46Opening and closing
and
47Opening and closing
Example 1:
2-D image
Original image Opening with 5 * 5 square SE Closing with 5 * 5 square SE
Width of lines is preserved
48Opening and closing
Example 2:
1-D signalOriginal 1-D signal
Flat SE, pushed up
underneath the signal
Opening
Flat SE, pushed down
along the top of the signal
Closing
Figure 9.36 of Gonzalez book
Generalization of flat dilation/erosion: instead of using min or max value
in window, use the p-th ranked value
Increases robustness against noise
Best-known example: median filter for noise reduction
Concept useful for both gray-level and binary images
All rank filters are commutative with thresholding
49Rank filter
example
Concepts are taken from MIT course slides
Gray-level images
Median filter: instead of using min or max
value in window, use median value
Binary images
Majority filter: instead of using min or max
value in window, use majority value
50Median filter and majority filter
example
example
Concepts are taken from MIT course slides
Gonzalez book:
Rafael C. Gonzalez, and Richard E. Woods. Digital image processing, Prentice Hall,
Inc., 2007
MIT course slides:
web.stanford.edu/class/ee368/Handouts/Lectures/2015_Autumn/7-
Morphological_16x9.pdf
51References
End of Lecture 10
Thank You!