You are on page 1of 47

Dr.

Muhammad Shahzad
Department Of Computing (DOC), SEECS, NUST
http://seecs.nust.edu.pk/faculty/muhammadshahzad.html
muhammad.shehzad@seecs.edu.pk
Spring 2019, MSCS-8
▪ Vehicle Re-Identification
▪ Person Re-Identification
▪ Traffic Flow Estimation / Road Traffic Analysis
▪ Semantic Segmentation of 3D Point Cloud
▪ Crop Health Monitoring Using Low Cost Drone
▪ Crop Health Monitoring Using Remote Sensing Data
▪ Forest Change Detection Using Remote Sensing Data
▪ Satellite Drone Data Fusion in Forest/Crop Applications
▪ Buildings Detection in Aerial Imagery
▪ 3D Building Modeling Using Point Cloud
▪ Crop Height Estimation
▪ Age Estimation / Person Identification / Terrain Classification
Using Inertial Sensor Data
▪ …
2
▪ Preliminaries – set theory
▪ Structuring Element(s)
▪ Dilation and erosion
▪ Opening and closing
▪ Hit-or-Miss transformation
▪ Some basic morphological algorithms
▪ Extensions to gray-scale images

3
▪ “Morphology “ – a branch in biology that deals with the form and
structure of animals and plants.

▪ “Mathematical Morphology” –
▪ as a tool for extracting image components, that are useful in the
representation and description of region shape.

▪ Therefore, morphological operations are intended to affect the shape


of the object

▪ The language of mathematical morphology is – Set theory.

▪ Unified and powerful approach to numerous image processing


problems.

4
▪ A tool for extracting image components that are useful in the
representation and description of region shape, such as

▪ boundaries extraction
▪ skeletons
▪ convex hull
▪ morphological filtering
▪ thinning Quick Example
▪ pruning

5
▪ The set space of binary image is Z2
▪ Each element of the set is a 2D vector whose coordinates are the
(x,y) of a black (or white, depending on the convention) pixel in the
image

▪ The set space of gray level image is Z3


▪ Each element of the set is a 3D vector: (x,y) and intensity level.

NOTE:
Set Theory and Logical operations are covered in:
Section 9.1, Chapter # 9, 2nd Edition DIP by Gonzalez
Section 2.6.4, Chapter # 2, 3rd Edition DIP by Gonzalez

6
7
8
9
▪ Operators by Example

10
▪ The translation of a set B by point z = (z1, z2), denoted (B)z, is
defined as

▪ If B is the set of pixels representing an object in an image, then


(B)z is the set of points in B whose (x, y) coordinates have been
replaced by (x + z1, y + z2)

reflection

translation

11
▪ Reflection of a set B, denoted as B^

▪ If B is the set of pixels (2-D points) representing an object in an


image, then B^ is simply the set of points in B whose (x,y)
coordinates have been replaced by (-x,-y)

reflection

translation

12
▪ A structuring element is a small image – used as a moving
window.

13
▪ Fundamentally morphological image processing is very like
spatial filtering.

▪ The structuring element is moved across every pixel in the


original image to give a pixel in a new processed image.

▪ The value of this new pixel depends on the operation


performed.

▪ Two basic morphological operations


▪ Erosion
▪ Dilation

14
fit hit

Fit: All of the pixels in the structuring


element cover on pixels in the image

Hit: Any one pixel in the structuring


element covers an on pixel in the image

All morphological processing operations are based on these simple ideas

15
▪ 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 is determined using the rule:

16
▪ With A and B as sets in Z2, the erosion of A by B is defined as

▪ In words, this equation indicates that the erosion of A by B is the


set of all points z such that B, translated by z, is contained in A

▪ Because the statement that B has to be contained in A is


equivalent to B not sharing any common elements with the
background, an equivalent expression can also be

17
Steps
▪ For each foreground pixel (which we will call the input pixel)

▪ Superimpose the structuring element on top of the input image so


that the origin of the structuring element coincides with the input
pixel position.

▪ If for every pixel in the structuring element, the corresponding


pixel in the image underneath is a foreground pixel, then the input
pixel is left as it is.

▪ If any of the corresponding pixels in the image are background,


however, the input pixel is also set to background value.

18
19
Foreground
Background
20
Basics
▪ Effects
▪ Shrinks the size of foreground (1-valued) objects
▪ It does smooth object boundaries
▪ Removes small objects

▪ Rule for Erosion


▪ In a binary image, if any of the pixel (in the neighbourhood
defined by structuring element) is 0, then output is 0

21
Basics

Watch out: Erosion shrinks objects


22
Results

23
Results

24
Results

25
Exercise 1

26
Exercise 2
▪ Using MATLAB, count the number or circles in the image below
through erosion and object labeling.

27
Exercise 2

28
29
Steps

31
Example

Foreground
Background 32
Example

Here it is assumed
that the center red
dot of the structuring
element should be
within the foreground
(blue square)

The dilation of dark-blue square by a disk, resulting in the


light-blue square with rounded corners

33
Basics
▪ Effects
▪ Expands the size of foreground (1-valued) objects.
▪ Smoothes object boundaries.
▪ Closes holes and gaps.

▪ Rule for Dilation


▪ In a binary image, if any of the pixel (in the neighbourhood
defined by structuring element) is 1, then output is 1.

34
Basics

35
Example 1

36
Example 2

37
Example 3

38
39
40
▪ Preliminaries – set theory
▪ Structuring Element(s)
▪ Dilation and erosion
▪ Opening and closing
▪ Hit-or-Miss transformation
▪ Some basic morphological algorithms
▪ Extensions to gray-scale images

41
▪ More interesting morphological operations can be performed
by performing combinations of erosions and dilations

▪ The most widely used of these compound operations are:


▪ Opening:
▪ Generally smoothes the contour of an object, breaks narrow
isthmuses and eliminates thin protrusions

▪ Closing
▪ Also tends to smooth sections of contours but, as opposed to
opening, it generally fuses narrow breaks and long thin gulfs,
eliminates small holes and fills gaps in the contour

42
43
44
45
46
47
Various contents in this presentation have been taken from
different books, lecture notes, and the web. These solely belong
to their owners, and are here used only for clarifying various
educational concepts. Any copyright infringement is not
intended.

48

You might also like