Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI...
Transcript of Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI...
![Page 1: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/1.jpg)
Digital Image Analysis and ProcessingCPE 0907544CPE 0907544
Morphological Image Processing
Chapter 9Sections : 9 1 – 9 5
D I d J f
Sections : 9.1 – 9.5
Dr. Iyad Jafar
![Page 2: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/2.jpg)
Outline
Introduction
Erosion and Dilation
Opening and Closing
B d EBoundary Extraction
Hole FillingHole Filling
Hit-or-Miss Transformation
2
![Page 3: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/3.jpg)
IntroductionMorphology as word describes a branch of biologythat deals with animal and plant structurethat deals with animal and plant structure
In the context of image processing , it refers to aIn the context of image processing , it refers to aset of mathematical tools that can be used to
extract useful description and representation of regionsextract useful description and representation of regionsin images (boundaries, skeletons, convex hull)remove imperfections introduced during segmentationp g g(thinning, regions filling)
Morphological operators can be formulated in anyn-dimensional Euclidean space (binary, gray scale,color)
3
![Page 4: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/4.jpg)
Introduction
Image after segmentation Image after segmentation g g g gand morphological
processing
4
![Page 5: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/5.jpg)
IntroductionA binary image can be considered as a setb id i “bl k” i l ( ith iby considering “black” pixels (with imagevalue “0”) as elements in the set and “white”pixels (with value “1”) as outside the set, orvice versa.
Morphological filters are essentially set operationsMorphological filters are essentially set operations5
![Page 6: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/6.jpg)
Basic Set OperationsLet x, y, z, … represent locations of 2D pixels, e.g. x= (x1, x2), S denotes the complete set of all pixels inan image, let A, B, … represent subsets of SUnion (OR)( )
Intersection (AND)
6
![Page 7: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/7.jpg)
Basic Set OperationsComplement
Translation
ReflectionReflection
7
![Page 8: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/8.jpg)
Structuring ElementsAll morphological operations are based on usingstructuring elements (similar to filter masks)
1 1 1
1 1 1
0 1 0
1 1 1
M h l i l i b d i h
1 1 1
1 1 1
1 1 1
0 1 0
Morphological operations are based moving thestructuring element over the image pixels to check for aHIT or FITHIT or FIT
FIT - all ON pixels in the structuring element cover ONpixels in the imagepixels in the image
HIT - any ON pixel in the structuring element covers anON pixel in the imageON pixel in the image
8
![Page 9: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/9.jpg)
Structuring Elements
B
Structuring Element
AA Fit AC
A – Fit B – Hit C MiC – Miss
9
![Page 10: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/10.jpg)
Structuring ElementsStructuring elements can be of any size and shapeRectangular shapes are usually used with the origin beingat the center pixel
0 0 1 0 01 1 1
1 1 1
1 1 1
0 1 0
1 1 1
0 1 0
0 1 1 1 0
1 1 1 1 1
0 1 1 1 0
Fundamentally morphological image processing is very like
0 0 1 0 0
Fundamentally morphological image processing is very likespatial filteringThe structuring element is moved across every pixel in theg y poriginal image to give a pixel in a new processed imageThe value of this new pixel depends on the operationperformed
10
![Page 11: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/11.jpg)
Structuring Elements0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 1 0 0 0 0 0 0 0 1 1 10 0 1 1 1 1 1 0 0 0 0 0
0 1 1 1 1 1 1 1 0 0 0 0B
C
1 1 1
1 1 1
1 1 1
0 1 1 1 1 1 1 1 0 0 0 0
0 0 1 1 1 1 1 1 0 0 0 0
Structuring Element 1
0 1 00 0 1 1 1 1 1 1 1 0 0 0
0 0 1 1 1 1 1 1 1 1 1 0
0 0 0 0 0 1 1 1 1 1 1 0A
0 1 01 1 10 1 0
0 0 0 0 0 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0 0 0 0Structuring Element 2
Location Structuring Element 1 Structuring Element 2
A FIT FIT
B HIT FIT
11
B HIT FIT
C HIT HIT
![Page 12: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/12.jpg)
ErosionErosion of image A by structuringl t B i i b A B h th telement B is given by A B such that
A B =f
{ | ( ) }zz B AA BThe structuring element B is
{ | ( ) }z
positioned with its origin at (x, y) andthe new pixel value is determined usingthe new pixel value is determined usingthe rule:
1 , if fits ( , )
0 other iseB A
g x y ⎧⎨⎩
12
0 , otherwise⎩
![Page 13: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/13.jpg)
ErosionExample 9.1Original Image Processed Image
* ** **
* Keep pixels at which the structuring element scores a FIT
Removed Pixels
Structuring Element
structuring element scores a FIT* Erosion shrinks objects Kept Pixels
![Page 14: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/14.jpg)
ErosionExample 9.2
Original image Erosion by 3*3 square structuring
Erosion by 5*5 square structuring
element element
W h I h l 1 f bl k l!Watch out: In these examples a 1 refers to a black pixel!
![Page 15: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/15.jpg)
ErosionExample 9.3
After erosionOriginal image
After erosion with a disc of radius 10
After erosion with a disc of
After erosion with a disc of
radius 20radius 5
![Page 16: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/16.jpg)
What Is Erosion For?
Erosion can split apart joined objects
Erosion can strip away extrusionsp y
![Page 17: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/17.jpg)
DilationDilation of image A by structuringl t B i i b A B h th telement B is given by A B such that
A B =^
{ | ( ) }zz B AA BThe structuring element B is
{ | ( ) }z
positioned with its origin at (x, y) andthe new pixel value is determined usingthe new pixel value is determined usingthe rule:
1 if hiB A⎧ 1 , if hits ( , )
0 otherwiseB A
g x y ⎧⎨⎩
17
0 , otherwise⎩
![Page 18: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/18.jpg)
DilationExample 9.4Original Image Processed Image
* Keep pixels at which the structuring element hits at least
Pixels added to object
Structuring Element
one ON pixel * Dilation enlarges objects
Kept Pixels
![Page 19: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/19.jpg)
DilationExample 9.5
Original image Dilation by 3*3 Dilation by 5*5Original image ysquare structuring
element
Dilation by 5 5 square structuring
element
Watch out: In these examples a 1 refers to a black pixel!
![Page 20: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/20.jpg)
DilationE l 9 6
Original image After dilation
Example 9.6
Structuring element
![Page 21: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/21.jpg)
What Is Dilation For?Dilation can repair breaks
Dilation can repair intrusionsDilation can repair intrusions
![Page 22: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/22.jpg)
OpeningThe opening operation on image A byt t i l t B i d fi dstructuring element B is defined as
A o B = (A B) BA o B (A B) Bin other words, it is erosion followedby dilationGenerally opening is used toGenerally, opening is used toSmooth the contour of an object (inner
)contour)Break narrow paths between large objectsEliminate thin protrusions
22
![Page 23: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/23.jpg)
OpeningExample 9.7
0 0 1 0 0
0 1 1 1 0
1 1 1 1 11 1 1 1 1
0 1 1 1 0
0 0 1 0 0
Original shapeAfter erosion
Structuring Element
Aft dil ti23
After dilation(opening)
![Page 24: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/24.jpg)
ClosingThe closing operation on image A bystructuring element B is defined asstructuring element B is defined as
A • B = (A B) Bin other words, it is dilation followed byerosionerosionGenerally, closing is used toS h h f bj (Smooth the contour of an object (outercontour)Fuse narrow paths between large objectsEliminate thin small holes and fill gaps in thecontour
24
![Page 25: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/25.jpg)
ClosingExample 9.8
0 0 1 0 0
0 1 1 1 0
1 1 1 1 1
0 1 1 1 0
0 0 1 0 0
Original shapeAfter dilation
Structuring Element
Aft i25
After erosion(Closing)
![Page 26: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/26.jpg)
Example 9.9White noise regions removedBlack regions within theBlack regions within the fingerprint have enlarged
Black regions within the fingerprint shrunken But gaps are introducedintroduced between ridges
26
![Page 27: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/27.jpg)
Boundary ExtractionThe boundary of set A denoted by (A) can beobtained by first eroding A by a suitabley g ystructuring element B then perform the setdifference between A and its erosionff
Erosion
27
![Page 28: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/28.jpg)
Boundary ExtractionExample 9.10
Boundary Extraction
Original binary image Boundary detected based on morphological operatorsmorphological operators
28 Structuring element
![Page 29: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/29.jpg)
Hole FillingfA hole may be defined as a background region surrounded
by a connected border of foreground pixels
The algorithm presented here assumes that we know onepixel for each hole in the image
Algorithm
Form an array X0 of the same size as A and initialize it withzeros except locations that correspond to pixels inside theregions to be filled
Apply the following equation iteratively on array X until Xk =Xk-1 to form the filled holes
( ) cX X B AThe original image with filled holes is found by
1( )k kX X B A
A X A29
filled kA X A
![Page 30: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/30.jpg)
Hole FillingExample 9.11
Original, Complement, and Structuring Element
30
![Page 31: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/31.jpg)
Hole FillingExample 9.12
Original One hole filled All holes filled
31
![Page 32: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/32.jpg)
Hit-or-Miss TransformationA basic tool for shape detectionSuppose we have an image A that consists of three objectspp g jC, D, and E and we want to detect the presence of shapeD; assuming we know its shape
Object E50x50
Object C200x100
Obj t DObject D80x80
32Image A
![Page 33: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/33.jpg)
Hit-or-Miss TransformationWe can start by eroding A with a structuring element thathas the same shape as Dhas the same shape as D
One pixel that represents the
center of object D
Structuring element
D
Erosion
objectD
Image A
However, the result may contain parts of larger objects
33
![Page 34: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/34.jpg)
Hit-or-Miss TransformationConsider the complement of A and a new structuringelement that is one pixel thicker than the objectelement that is one pixel thicker than the object
One pixel that represents the center
Structuring element 82x82
Erosionp
of object D
W-D
Complement of A
Note how the center of object D was detected again !
34
![Page 35: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/35.jpg)
Hit-or-Miss TransformationConsider the intersection of the erosion results from theprevious two slidesprevious two slides
Intersection
Object is s ccessf ll l cated !Object is successfully located !Formally, the hit-or-miss transformation on image A todetect some object X is performed bydetect some object X, is performed by
where W is a the object X thickened by one pixel35
![Page 36: Digital Image Analysis and Processing CPE 0907544CPE 0907544 … · Chapter 9 Sections :91– 95 DI dJf Sections : 9.1 9.5 Dr. Iyad Jafar. Outline yIntroduction yErosion and Dilation](https://reader034.fdocuments.in/reader034/viewer/2022050309/5f711c247ae33353771e8cc3/html5/thumbnails/36.jpg)
Related Matlab Functionsimerode
imdilate
imopen
I lImclose
strelstrel
bwmorphp
36