Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
24 views

Digital Image Processing - Lecture-10

This document contains information about a Digital Image Processing course taught by Dr. Mai Kamal El Den including: - The course textbook and link to the Microsoft Teams page. - The grading formula which includes weights for exams, quizzes, and semester work. - An overview of morphological image processing including common operations like dilation and erosion using structuring elements.

Uploaded by

fatacex396
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Digital Image Processing - Lecture-10

This document contains information about a Digital Image Processing course taught by Dr. Mai Kamal El Den including: - The course textbook and link to the Microsoft Teams page. - The grading formula which includes weights for exams, quizzes, and semester work. - An overview of morphological image processing including common operations like dilation and erosion using structuring elements.

Uploaded by

fatacex396
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Dr Mai Kamal DIP 2022

Digital Iamge Processing


Course
By
Dr. Mai Kamal El Den
Lecturer, Computer Science Department,
Faculty of Computers and Artificial Intelligence,
Benha University

Dr Mai Kamal DIP 2022


Digital Iamge Processing Course

Dr Mai Kamal DIP 2022

Digital Iamge Processing


Course

Teams Link
https://teams.microsoft.com/l/team/19%3aV89kJ8amsbE3ssF9V0x
mGOukoYKvZIwPVey1-
EUiL4Y1%40thread.tacv2/conversations?groupId=47e1fe88-6e6b-
433e-b771-94c21eeb96c6&tenantId=ff4a48d6-4b5e-4fd3-8266-
7eafc3e6e23e

Dr Mai Kamal DIP 2022


Grading Formula

Weights of the Assessments


Final Term Examination 50
Midterm Exam 15
Practical Exam 15
Quiz 1 5
Quiz 2 5
Semester Work 10

Dr Mai Kamal DIP 2022

Text Book

R. Gonzalez, R. Woods.
Digital Ιmage Processing,
Prentice Hall, 2008.
Third Edition .

Dr Mai Kamal DIP 2022


Digital Iamge Processing Course

Lecture 10
Morphological Image Processing

Dr Mai Kamal DIP 2022

Morphology
 Morphology is a tool for extracting image
components.
 Morphology removes unwanted elements from binary
images.
 Morphological operations are intended to affect the
shape of the object.
 Morphological operations are typically applied
to remove imperfections introduced during
segmentation, and so typically operate on bi-level
images.

Dr Mai Kamal DIP 2022


Morphological Operations

– Hit – Fit
– Dilation – Erosion
– Opening – Closing

Dr Mai Kamal DIP 2022

Morphology
 Morphological image processing is used to extract
image components for representation and description
of region shape, such as:
– Boundaries Extraction
– Convex Hull
– Morphological Filtering
– Thinning
– Skeletons
– Pruning

Dr Mai Kamal DIP 2022


Uses of Morphology

Remove noise: Remove noise: Isolating Customized to


Filling holes. objects specific shapes
Removing
small objects
Dr Mai Kamal DIP 2022

How does it work?

 Grayscale image
 Preprocessing
– Inversion
 Threshold => Binary image
 Morphology

Dr Mai Kamal DIP 2022


Morphological Image processing
 Structure Elements (SE)
– Small sets or sub-images used to probe an image under
study for properties of interest.
– Choose appropriate SE and morphological operations
based on image content.

origin

Dr Mai Kamal DIP 2022

Structure Elements
 Structuring elements can be any size and make
any shape.
 However, for simplicity we will use rectangular
structuring elements with their origin at the middle
pixel.

Dr Mai Kamal DIP 2022


Examples: Structuring Elements
Accommodate the
entire structuring
elements when its Origin of B visits
origin is on the every element of A
border of the
original set A
At each location of
the origin of B, if B
is completely
contained in A,
then the location is
a member of the
new set, otherwise
it is not a member
of the new set.

Dr Mai Kamal DIP 2022

Structuring Elements, Hits & Fits (cont.)

 Hits & Fits


Structuring Element

 Hit: Any one pixel in the structuring


element covers any one pixel in
the image.
 Fit: All one pixels in the structuring
element cover one pixels in the
image.

Note: All morphological processing operations are based on these


simple ideas.
Dr Mai Kamal DIP 2022
Structuring Elements, Hits & Fits (cont.)

 Fitting & Hitting Example

Dr Mai Kamal DIP 2022

Morphology : The hit operation

 For each “1” in the structuring element we investigate whether the


pixel at the same position in the image is also a “1”.
– If just one 1 in the SE match with the input
• output 1
– else
• output 0

22
Morphology : The fit operation

 For each “1” in the structuring element we investigate whether


the pixel at the same position in the image is also a “1”.
– If all 1 in the SE match with the input
• output 1
– else
• output 0

23

2D Morphology : Result of hit and


fit operation
Position SE Fit Hit
A S1 No Yes

A S2 No Yes

B S1 No Yes

B S2 No No

C S1 Yes Yes

C S2 Yes Yes

D S1 No No
No No
D S2

24
Simple Morphological Operations
 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.

 There are two basic morphological operations: - erosion


and - dilation .
Dr Mai Kamal DIP 2022

Dilation
 Dilate : To make wider or larger
 Applying Hit to an entire image is denoted
Dilation

26
Simple Morphological Operations (cont.)

 Dilation
 Dilation of image 𝑓 by structuring element 𝑠 is
given by
𝒇⊕𝒔
 The structuring element 𝑠 is positioned with its
origin at (𝑥, 𝑦) and the new pixel value is
determined using the rule:

Dr Mai Kamal DIP 2022

Simple Morphological Operations (cont.)

 Dilation Example1

H H H
H H H H H
Structuring
H H H H H H
Element
H H H H H H
H H H H H
H H H H H
H H H

 Fully matched => 1


 Some matched => 1
 No matched =>0
Dr Mai Kamal DIP 2022
Simple Morphological Operations (cont.)

 Dilation Example2

• In these examples a 1 refers to a black pixel!

Dr Mai Kamal DIP 2022

Simple Morphological Operations (cont.)

 Dilation Example3

Dr Mai Kamal DIP 2022


Applying the Dilation Operation

 Dilation with different sized structuring elements


32

Erosion
 Erode : To wear down (Waves eroded the shore)
 Applying Fit to an entire image is denoted Erosion

33
Simple Morphological Operations (cont.)

 Erosion
 Erosion of image 𝑓 by structuring element 𝑠 is
given by
𝒇⊝𝒔
 The structuring element 𝑠 is positioned with its
origin at (𝑥, 𝑦) and the new pixel value is
determined using the rule:

Dr Mai Kamal DIP 2022

Simple Morphological Operations (cont.)

 Erosion Example1

Structuring
F F Element
F F
F

Dr Mai Kamal DIP 2022


Simple Morphological Operations (cont.)

 Erosion Example2

29/29

Dr Mai Kamal DIP 2022

Simple Morphological Operations (cont.)

 Erosion Example3

 In these examples a 1 refers to a black pixel!

Dr Mai Kamal DIP 2022


Simple Morphological Operations (cont.)

 Erosion Example5

 Erosion can split apart joined objects

 Erosion can strip away extrusions

 Erosion shrinks objects

Dr Mai Kamal DIP 2022

Applying the Erosion Operation

40
Compound Operations

 More interesting morphological operations can be


performed by performing combinations of erosions
and dilations.

 The most widely used of these compound


operations are:

– Opening

– Closing

Dr Mai Kamal DIP 2022

Compound Operations
 Combining Erosion
and Dilation into more
advanced operations
– Finding the outline
– Opening
• Isolate objects and
remove small objects
(better than Erosion)
– Closing
• Fill holes (better than
Dilation)

43
Opening
 Objects decrease when we use erosion to erase
small noisy objects or fractured parts of bigger
objects.
 Enlarge the object by following the erosion by
dilation. This operation is denoted Opening.
 Motivation: Remove small objects BUT keep
original size (and shape)
 Opening = Erosion + Dilation
– Use the same structuring element!

44

Compound Operations (cont.)

 Opening
 The opening of image 𝑓 by structuring element 𝑠,
denoted
𝒇 ○ 𝒔 is simply an erosion followed by a dilation
𝒇 ○ 𝒔 = (𝒇 ⊝ 𝒔) ⊕ s

Note a disc shaped structuring element is used

Dr Mai Kamal DIP 2022


Compound Operations (cont.)

 Opening Example2

H
F Structuring H F H
Element H

Dr Mai Kamal DIP 2022

Compound Operations (cont.)

 Opening Example3
Structuring
Element

After Fit After Hit

Dr Mai Kamal DIP 2022


Opening

erosion dilation
F H

 Opening of the binary image using S1


 Opening is idempotent: Repeated operations has no further
effects!

48

Applying the Opening Operation

erosion dilation

 Opening performed using 7 × 7 box-shaped


structuring elements.
49
Opening example
 Size of structuring element should fit into
the smallest object to keep
 Structuring Element: 11 pixel disc

50

Compound Operations (cont.)

 Closing
 The closing of image 𝑓 by structuring element 𝑠,
denoted 𝒇•𝒔 is simply a dilation followed by an
erosion
𝒇 • 𝒔 = (𝒇 ⊕ 𝒔) ⊝s

Note a disc shaped structuring element is used

Dr Mai Kamal DIP 2022


Closing
 The objects increase in size when we use
dilation to fill the holes in objects.
 shrink the object by following the Dilation by an
Erosion. This operation is denoted Closing.
 Motivation: Fill holes BUT keep original size
(and shape)
 Closing = Dilation + Erosion
– Use the same structuring element!

52

Applying the Closing Operation

dilation erosion

 Closing performed using 7 × 7 box-shaped


structuring elements.
54
Closing example
 Closing operation with a 22 pixel disc
 Closes small holes

55

Compound Operations (cont.)

 Properties of Opening and Closing


 Opening
(i) A  B is a subset (subimage) of A
(ii) If C is a subset of D, then C  B is a subset of D  B
(iii) ( A  B)  B  A  B
 Closing
(i) A is a subset (subimage) of A  B
(ii) If C is a subset of D, then C  B is a subset of D  B
(iii) ( A  B)  B  A  B

Dr Mai Kamal DIP 2022


Use of Opening and Closing for Morphological
Filtering

Dr Mai Kamal DIP 2022

Hit-or-Miss Transform

 Used to look for particular patterns of foreground and


background pixels in an image.
 Very simple object recognition
 All the other binary morphological operators can be derived
from it.
 Hit or miss transform have the form :
 Input
 Binary image. × ×

 Structure element, containing 0s and 1s and don’t


care!!
 output ×
 Binary image

Dr Mai Kamal DIP 2022


Morphological Algorithms

 Used to extract image components that are useful


in the representation and description of region
shape, such as
1. Boundaries Extraction
2. Region Filling
3. Extraction of Connected Components
4. Convex Hull
5. Thinning
6. Thickening

Dr Mai Kamal DIP 2022

Morphological Algorithms (cont.)

1. Boundary Extraction
 Extracting the boundary (or outline) of an object is often
extremely useful
 The boundary can be given simply as
𝜷(𝑨) = 𝑨 – (𝑨 ⊝ 𝑩)

Dr Mai Kamal DIP 2022


Morphological Algorithms (cont.)

 Boundary Extraction Example1


 A simple image and the result of performing
boundary extraction using a square 3*3 structuring
element.

Dr Mai Kamal DIP 2022

Morphological Algorithms (cont.)

2. Region Filling
 Given a pixel inside a boundary, region filling
attempts to fill that boundary with object pixels (1s)

Dr Mai Kamal DIP 2022


Morphological Algorithms (cont.)

How?
 Idea: place a given point 𝒑 (initial point) inside the region,
then dilate that point iteratively.

 Result: given by union of 𝑨 and 𝑿𝒌 ,

Dr Mai Kamal DIP 2022

Morphological Algorithms (cont.)

Region Filling Example1


Initial point inside
the boundary

Dr Mai Kamal DIP 2022


Morphological Algorithms (cont.)

Region Filling Example2


 The objective is to eliminate the dark spots by region
filling.

29/29

Dr Mai Kamal DIP 2022

Morphological Algorithms (cont.)

3. Extraction of Connected Components


 This algorithm extracts a component by selecting a point on a binary object 𝐴.
 Works similar to region filling, but this time we use in the intersection the object 𝐴,
instead of it’s complement.
Idea: start from a point in the connected component, and dilate it iteratively

Result: If 𝑿𝒌 = 𝑿𝒌−𝟏, the algorithm has converged and the result is 𝑿𝒌 that contains
all the connected components of the input image. 26/34
Morphological Algorithms (cont.)

Extraction of Connected Components Example1


Initial point 𝒑
First Step

Second Step Final Step

29/29

Morphological Algorithms (cont.)

4. Convex Hull
 𝐴 is said to be convex if a straight line segment joining any two points in 𝐴 lies
entirely within 𝐴.

29/29
Morphological Algorithms (cont.)

 We present simple algorithm for obtaining the convex hull 𝐶(𝐴) of a set 𝐴.
 This algorithm iteratively applying the hit-or-miss transform to 𝐴 with the first of 𝐵
element, unions it with 𝐴, and repeated with second element of 𝐵.
 Let 𝐵𝑖 , 𝑖=1,2,3,4 represent the four structuring elements. The procedure consists
of implementing the equation:

with . When the procedure converges (i.e., when ), we let


Then the convex hull of 𝐴 is

29/34

Morphological Algorithms (cont.)

Convex Hull Example

29/29
Morphological Algorithms (cont.)

Thinning

5. Thinning
 Thinning is the transformation of a digital image into a simplified.
 The thinning of a set 𝐴 by a structuring element 𝐵, can be defined by terms of the
hit-and-miss transform:

 If 𝐵 is a sequence of structuring elements:

where 𝐵𝑖 is a rotated version of 𝐵𝑖−1 .


 Then the thinning of A by a sequence of structuring element {B} is defined by:
31/34

Morphological Algorithms (cont.)

Thinning Example

29/29
Morphological Algorithms (cont.)

Thickening

6. Thickening
 Thickening is the morphological dual of thinning and is defined by the expression

where 𝐵 is a structuring element suitable for thickening.

 Thickening can be defined as a sequential operation:

33/34

Morphological Algorithms (cont.)

Thickening Example Structure elements

34/34
Dr Mai Kamal DIP 2022

You might also like