Morphology in image processing Morphology generally concerned with shape and properties of objects.. Digital Image ProcessingErosion and Dilation... Dilation and Erosionan object bounda
Trang 1Morphology in image processing
Morphology generally concerned with shape
and properties of objects
Used for segmentation and feature extraction
Segmentation = used for cleaning binary
objects.
Two basic operations
erosion
dilation
Trang 2Digital Image Processing
Erosion and Dilation
Trang 3Dilation and Erosion
an object
boundary of an object
depends on size and shape of structuring element
Trang 4Morphological operators are used to prepare
recognition
(specifically salt-and-pepper noise)
black pixels in a white region) Can also have
cracks, picket fence occlusions, etc.
morphological operations that can assist with these problems.
Morphology in image processing
Trang 5Union of A and B: C=A∪B
Intersection of A and B: D=A∩B
Disjoint sets: A∩B= ∅
Complement of A: Ac = {x|x∉A}
Difference of A and B:
A-B = {x|x ∈ A, x ∉ B} = A ∩Bc
Trang 6Structuring Elements, Hits & Fits
on pixels in the image
Hit: Any on pixel in the structuring element covers
an on pixel in the image
All morphological processing operations are based
on these simple ideas
Trang 7Structuring 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
Trang 8Fitting & Hitting
0 1 0
1 1 1
0 1 0
Structuring Element 2
Trang 9Fundamental Operations
processing is very like spatial filtering
every pixel in the original image to give a pixel in a new processed image
operation performed
Trang 10Erosion 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:
fits if
1 )
,
g
Trang 11Example for Erosion
1 1
0 1
1 1
0 0
0 1
Input image
Structuring Element
x7 x6
x5 x4
x1 x3
x2 x1
Output Image
1 1
1
Trang 12Erosion Example
Structuring Element Original Image Processed Image With Eroded Pixels
Trang 13Erosion Example
Structuring Element
Original Image Processed Image
Trang 15Erosion Example
A
Trang 16Erosion Example
Trang 20Erosion Example 2
Original image
After erosion with a disc of radius 10
After erosion with a disc of radius 20
Trang 21Dilation 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:
hits if
1 )
,
g
Trang 22Example for Erosion
1 1
0 1
1 1
0 0
0 1
Input image
Structuring Element
x3 x2
x1
Output Image
1 1
1
Trang 23Dilation Example
Structuring Element Original Image Processed Image
Trang 24Dilation Example
Structuring Element Original Image Processed Image With Dilated Pixels
Trang 25Dilation Example
Trang 27Main Applications of Dilation
Trang 28Dilation Example
Trang 29Main Applications of Dilation
Trang 31Main Applications of Dilation
Trang 32Main Applications of Dilation
Trang 33clear all;
clc
A=imread('Fill_hold.bmp'); B=im2bw(A);
Trang 34Dilation: expands image
Erosion: shrink image
erosion+dilation = original image ?
Opening= erosion + dilation
B B
A B
A = ( ) ⊕
Trang 35Closing
Closing = dilation + erosion
B B
A B
A • = ( ⊕ )
Trang 36Example of opening and closing
Trang 37se=strel(‘square', 20);
(A) Original Image (B) Opening
(C) closing (D) Closing of B
Trang 38(A) Original Image (B) Opening
(C) closing (D) Closing of B
se=strel('disk', 10);
Trang 39(A) Original Image (B) Opening
(C) closing (D) Closing of B
Trang 40closing
Trang 41From A -> B -> C, counting the number of objects, highlight the boundary of
objets (Boundary Extraction)
Trang 42exercises
Trang 43The Hit-or-Miss Transformation
Trang 44Use the hit-or-miss trnsformation to identify the location of the shape
Trang 47Use the hit-or-miss trnsformation to identify the location of the shape
Trang 49bwmorph(f, operation, n)
based on combinations of dilations, erosions and look up table operations
Trang 50bwmorph(f, operation, n)
Trang 53bwmorph(f, operation, n)
BW2 = bwmorph(BW,'remove');
figure, imshow(BW2)
Trang 54bwmorph(f, operation, n)
Trang 55bwmorph(f, operation, n)
Trang 56Labeling Connected Components
• Label objects in an image
• 4-Neighbors
• 8-Neighbors
Trang 574 and 8 Connect
Input Image 8 – Connect 4 - Connect
Trang 584-Neighbors