Professional Documents
Culture Documents
L4 Morphological Operations
L4 Morphological Operations
Name of Faculty:
Dr. Umesh Sahu
(Assistant Professor)
Manipal Institute of Technology, Manipal, India
−1−
Syllabus
Image acquisition and pre-processing: [15]
Vision system components, Image acquisition and analysis, Image
formation - Sampling & Quantization, simple operations on image,
Image enhancement Spatial Domain and frequency domain methods,
Image noise, image restoration, morphological operations,
Segmentation, image analysis, representation of regions, Feature
extraction, fundamentals of color image processing, conversion of
color spaces.
▪ Mathematical morphology used as 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
– pruning
Ac = w | w A
• “Subset”
– A is a subset of B if every element of A is also in B
A B
https://homepages.inf.ed.ac.uk/rbf/HIPR2/morops.htm
▪Choice of SE
–Different size & shape of SE yields different kinds of info about the object;
–shapes the regions in different ways
https://homepages.inf.ed.ac.uk/rbf/HIPR2/morops.htm
MATLAB: SE = strel(‘shape', r)
Creates a shape: diamond/line/square
structuring element, where r specifies
the distance from the structuring element
origin to the points of the diamond.
▪ The erosion of A by B is the set of all structuring element origin locations where
the translated B does not overlap with the background of A.
▪ The basic effect of the operator on a binary image is to erode away the
boundaries of regions of foreground pixels (i.e. white pixels, typically).
▪ Thus areas of foreground pixels shrink in size, and holes within those areas
become larger.
Manipal Institute of Technology, Manipal, India
− 15 −
Erosion: Example
▪ Suppose that the structuring element is a 3×3 square .
▪ Note that in subsequent diagrams, foreground pixels are represented by 1's and background pixels
by 0's.
▪ The structuring element is now superimposed over each foreground pixel (input pixel ) in the
image.
– If all the pixels below the structuring element are foreground pixels then the input pixel retains
it’s value.
– But if any of the pixels is a background pixel then the input pixel gets the background pixel
value.
1 1 1
1 1 1
1 1 1
Structuring element
Radius r r
AӨB
w
w
w AӨB
AӨB = z | (B)z A
• Interpretation: shift B by z, if it is completely inside A, output a 1
Origin of B
Write the
output…
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1
B
1
1
A AӨB
https://homepages.inf.ed.ac.uk/rbf/HIPR2/erode.htm
Example 9.1
▪ This equation is based on obtaining the reflection of B about its origin and
translation (shifting) this reflection by z. Then, the dilation of A by B is the set
of all structuring element origin locations where the reflected and
translated B overlaps with A at least one element.
1 1 1
1 1 1
1 1 1
Structuring element
Radius r r
AB
w
w AB
Example 9.2
1 1
1 1
B
1
1 1
1 1
1 1
B̂
A A B
Origin of B
1 1
1
1
1
B B̂
1 1
1
A
A B
• OpenCV Python
• cv2.erode()
• cv2.dilate()
• https://www.geeksforgeeks.org/erosion-dilation-images-using-opencv-
python/
http://en.wikipedia. org/wiki/Mathematical_morphology
Example 9.3
Example 9.3
Example 9.4
• OpenCV Python
• cv2.morphologyEx()
• https://www.geeksforgeeks.org/python-morphological-operations-in-image-
processing-opening-set-1/
• https://www.geeksforgeeks.org/python-morphological-operations-in-image-
processing-closing-set-2/