binary image morphology - suraj @ lumssuraj.lums.edu.pk/~cs436a02/lecture 13 - handout.pdf · 1...
TRANSCRIPT
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
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
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
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
5
Real Example
Closing / Opening Operations
Closing: B ● S = (B ⊕ S) ө SOpening: B ◦ S = (B ө S) ⊕ SEffect?
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
7
Opening/Closing Example
Original Closing Opening
Logical Subtraction
A – B = A ∩ (NOT B)
A
B
A - B
B - A
8
Application Example
Problem: To find defects in manufactured gear heads for watches
Threshold - 140
Detection of Holes
RL RS RL- RS
Structuring Element
9
Covering of Holes
Dilate
Covering of Holes
OR
10
OPEN
Er + Di
A = Dilate to make same size as diskB = Dilate a little to cover teethB-A
AND
11
Dilation Subtraction, Dilation, OR
Connected Components
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
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