Binary Image Morphology - Suraj @ LUMSsuraj.lums.edu.pk/~cs436a02/Lecture 13 - handout.pdf · 1...
Transcript of Binary Image Morphology - Suraj @ LUMSsuraj.lums.edu.pk/~cs436a02/Lecture 13 - handout.pdf · 1...
![Page 1: Binary Image Morphology - Suraj @ LUMSsuraj.lums.edu.pk/~cs436a02/Lecture 13 - handout.pdf · 1 Binary Morphology Connected Component Labeling Region Props Lecture 13 17-10-02 Binary](https://reader033.fdocuments.us/reader033/viewer/2022051601/5ad0772a7f8b9a1d328e5300/html5/thumbnails/1.jpg)
1
Binary MorphologyConnected Component LabelingRegion Props
Lecture 1317-10-02
Binary Image Morphology
InputsBinary Image BStructuring Element STypically, S is also a binary image of small size
OutputS is applied to B
![Page 2: Binary Image Morphology - Suraj @ LUMSsuraj.lums.edu.pk/~cs436a02/Lecture 13 - handout.pdf · 1 Binary Morphology Connected Component Labeling Region Props Lecture 13 17-10-02 Binary](https://reader033.fdocuments.us/reader033/viewer/2022051601/5ad0772a7f8b9a1d328e5300/html5/thumbnails/2.jpg)
2
Structuring Elements
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
BOX(3,5)
1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1
DISK(5)
1 1 1
1 1
1 1
1 1
1 1 1
RING(5)
1 1
1 1
1 1 1 1
1 1 1 1
1 1
1 1
1 1
1 1
1 1
1
1
1
1 1
1
1
1
1
1
1
1
Dilation Example
1 1 1 1
1 1
1 1
1 1 1
1 1
1 1
1 1
1 1
1 1 1 1
1 1
1
1
1
1 1
1 1
1 1
1
1
1
1 1
1 1
1 1
1 1 1 1
1 1 1
1 1 1
1 1 1
1 1
1 1
1 1
1 1
1 1 1 1
1 1
![Page 3: Binary Image Morphology - Suraj @ LUMSsuraj.lums.edu.pk/~cs436a02/Lecture 13 - handout.pdf · 1 Binary Morphology Connected Component Labeling Region Props Lecture 13 17-10-02 Binary](https://reader033.fdocuments.us/reader033/viewer/2022051601/5ad0772a7f8b9a1d328e5300/html5/thumbnails/3.jpg)
3
Example –Dilation by BOX(3,3)
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1
1 1 1 1
1 1
1 1
1 1
1 1
1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1
1
1
1
1
1
1
1
1 1 1 1
1 1
1 1
1 1 1
1 1
1 1
1 1
1 1
1 1 1 1
1 1
Real Example
![Page 4: Binary Image Morphology - Suraj @ LUMSsuraj.lums.edu.pk/~cs436a02/Lecture 13 - handout.pdf · 1 Binary Morphology Connected Component Labeling Region Props Lecture 13 17-10-02 Binary](https://reader033.fdocuments.us/reader033/viewer/2022051601/5ad0772a7f8b9a1d328e5300/html5/thumbnails/4.jpg)
4
Erosion Example
1 1 1 1
1 1
1 1
1 1 1
1 1
1 1
1 1
1 1
1 1 1 1
1 1
1
1
1
1 1
1 1
1 1
1
1
1
1 1
1 1
1 1
1 1 1 1
1
1
1
1 1
1 1
1 1
1 1
1 1 1 1
1 1
Example –Erosion by BOX(3,3)
1 1 1 1
1 1
1 1
1 1 1
1 1
1 1
1 1
1 1
1 1 1 1
1 1
1
1
1
1
1
1
![Page 5: Binary Image Morphology - Suraj @ LUMSsuraj.lums.edu.pk/~cs436a02/Lecture 13 - handout.pdf · 1 Binary Morphology Connected Component Labeling Region Props Lecture 13 17-10-02 Binary](https://reader033.fdocuments.us/reader033/viewer/2022051601/5ad0772a7f8b9a1d328e5300/html5/thumbnails/5.jpg)
5
Real Example
Closing / Opening Operations
Closing: B ● S = (B ⊕ S) ө SOpening: B ◦ S = (B ө S) ⊕ SEffect?
![Page 6: Binary Image Morphology - Suraj @ LUMSsuraj.lums.edu.pk/~cs436a02/Lecture 13 - handout.pdf · 1 Binary Morphology Connected Component Labeling Region Props Lecture 13 17-10-02 Binary](https://reader033.fdocuments.us/reader033/viewer/2022051601/5ad0772a7f8b9a1d328e5300/html5/thumbnails/6.jpg)
6
Closing (Dilation followed by Erosion)
1 1 1 1
1 1
1 1
1 1 1
1 1
1 1
1 1
1 1
1 1 1 1
1 1
1 1 1 1
1 1 1
1 1 1
1 1 1
1 1
1 1
1 1
1 1
1 1 1 1 1
1 1
Opening(Erosion followed by Dilation)
1 1 1 1
1 1
1 1
1 1 1
1 1
1 1
1 1
1 1
1 1 1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
![Page 7: Binary Image Morphology - Suraj @ LUMSsuraj.lums.edu.pk/~cs436a02/Lecture 13 - handout.pdf · 1 Binary Morphology Connected Component Labeling Region Props Lecture 13 17-10-02 Binary](https://reader033.fdocuments.us/reader033/viewer/2022051601/5ad0772a7f8b9a1d328e5300/html5/thumbnails/7.jpg)
7
Opening/Closing Example
Original Closing Opening
Logical Subtraction
A – B = A ∩ (NOT B)
A
B
A - B
B - A
![Page 8: Binary Image Morphology - Suraj @ LUMSsuraj.lums.edu.pk/~cs436a02/Lecture 13 - handout.pdf · 1 Binary Morphology Connected Component Labeling Region Props Lecture 13 17-10-02 Binary](https://reader033.fdocuments.us/reader033/viewer/2022051601/5ad0772a7f8b9a1d328e5300/html5/thumbnails/8.jpg)
8
Application Example
Problem: To find defects in manufactured gear heads for watches
Threshold - 140
Detection of Holes
RL RS RL- RS
Structuring Element
![Page 9: Binary Image Morphology - Suraj @ LUMSsuraj.lums.edu.pk/~cs436a02/Lecture 13 - handout.pdf · 1 Binary Morphology Connected Component Labeling Region Props Lecture 13 17-10-02 Binary](https://reader033.fdocuments.us/reader033/viewer/2022051601/5ad0772a7f8b9a1d328e5300/html5/thumbnails/9.jpg)
9
Covering of Holes
Dilate
Covering of Holes
OR
![Page 10: Binary Image Morphology - Suraj @ LUMSsuraj.lums.edu.pk/~cs436a02/Lecture 13 - handout.pdf · 1 Binary Morphology Connected Component Labeling Region Props Lecture 13 17-10-02 Binary](https://reader033.fdocuments.us/reader033/viewer/2022051601/5ad0772a7f8b9a1d328e5300/html5/thumbnails/10.jpg)
10
OPEN
Er + Di
A = Dilate to make same size as diskB = Dilate a little to cover teethB-A
AND
![Page 11: Binary Image Morphology - Suraj @ LUMSsuraj.lums.edu.pk/~cs436a02/Lecture 13 - handout.pdf · 1 Binary Morphology Connected Component Labeling Region Props Lecture 13 17-10-02 Binary](https://reader033.fdocuments.us/reader033/viewer/2022051601/5ad0772a7f8b9a1d328e5300/html5/thumbnails/11.jpg)
11
Dilation Subtraction, Dilation, OR
Connected Components
![Page 12: Binary Image Morphology - Suraj @ LUMSsuraj.lums.edu.pk/~cs436a02/Lecture 13 - handout.pdf · 1 Binary Morphology Connected Component Labeling Region Props Lecture 13 17-10-02 Binary](https://reader033.fdocuments.us/reader033/viewer/2022051601/5ad0772a7f8b9a1d328e5300/html5/thumbnails/12.jpg)
12
Connected Components
Definition: Connected Pixels A pixel [r,c] is connected to pixel [r’,c’] if there
exists a sequence[r,c]=[r0,c0], [r1,c1], …, [rn,cn] = [r’,c’]in which B[ri,ci]=1 and [ri, ci] and [ri-1, ci-1] are neighbors for 1 ≤ i ≤ n
Definition: Connected ComponentA connected component is a set of pixels C such
that every pair of pixels in C is connected.
Connected Component Labeling
Find all connected components, give unique label to eachRecursive Code
For each unlabeled ON pixel, assign it a unique labelFollow neighbors (4 connected or 8 connected) recursively, and assign each unlabeled ON pixel assign it the same label
![Page 13: Binary Image Morphology - Suraj @ LUMSsuraj.lums.edu.pk/~cs436a02/Lecture 13 - handout.pdf · 1 Binary Morphology Connected Component Labeling Region Props Lecture 13 17-10-02 Binary](https://reader033.fdocuments.us/reader033/viewer/2022051601/5ad0772a7f8b9a1d328e5300/html5/thumbnails/13.jpg)
13
Connected Component Labeling
Non recursive algorithms, parallel algorithms also existIdea for Non-recursive code:
Process only two rows at a timeIf connected pixels are found, assign them same labelsIn the end, find equivalences
Region Properties
AreaCentroidBounding BoxPerimeter (connectivity definitions)Perimeter LengthCircularity Definitions2nd Moments, relation with elliptical shapes