SlideShare une entreprise Scribd logo
1  sur  30
Télécharger pour lire hors ligne
Lecture 3: Basic Morphological Image
Processing
Harvey Rhody
Chester F. Carlson Center for Imaging Science
Rochester Institute of Technology
rhody@cis.rit.edu
September 13, 2005
Abstract
Morphological processing is constructed with operations on sets of
pixels. Binary morphology uses only set membership and is indifferent
to the value, such as gray level or color, of a pixel. We will examine
some basic set operations and their usefulness in image processing.
DIP Lecture 3
Morphology and Sets
We will deal here only with morphological operations for binary images.
This will provide a basic understanding of the techniques. Morphological
processing for gray scale images requires more sophisticated mathematical
development.
Morphological processing is described almost entirely as operations on sets.
In this discussion, a set is a collection of pixels in the context of an image.
Our sets will be collections of points on an image grid G of size N × M
pixels.
DIP Lecture 3 1
Pixel Location
A set A of pixels in G can be described by giving a list of the pixel locations.
The locations can be given as a list of index positions from G that are
included in A.
If G is of size N × M then the index positions are the integers in the range
[0, MN − 1]. For [N, M] = [7, 3] the index grid is
G =
0 1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
A pixel in column x and row y has index p = x + Ny. Given p one can find
the column and row coordinates by
x = p mod N
y = p/N
DIP Lecture 3 2
Set Operations
Let A and B be sets. If a is the index of a pixel in A, then we write a ∈ A.
If a is not in A we write a /
∈ A.
If every element that is in A is also in B then A is a subset of B, written
A ⊆ B
This is equivalent to the statement a ∈ A ⇒ a ∈ B.
The union of A and B is the collection of all elements that are in one or
both set. The union is the set represented by C = A ∪ B. We can write
C = {p|p ∈ A or p ∈ B (or both)}
DIP Lecture 3 3
Set Operations
Set A is the white object in the black
box on the right. The image grid G is the
N ×M black rectangle that holds the set.
In IDL programs we write a set A as an
array whose background values are zero
and object values are not zero.
We can find the coordinates of the object
by
p = WHERE(A)
x = p mod N
y = p/N
DIP Lecture 3 4
Set Operations - Union
The operation
C = A ∪ B
produces a set that contains
the elements of both A and B.
The fact that some elements
are represented in both sets
(red pixels) does not affect the
result.
Note that B itself contains
two disjoint subsets.
Set A Set B
Overlap (red) A ∪ B
DIP Lecture 3 5
Set Operations (cont)
The intersection of two sets A and B is
D = A ∩ B = {p|p ∈ A and p ∈ B}
It is possible that A and B have no common elements. In that case, we say
that they are disjoint and write
A ∩ B = ∅
where ∅ is the name for the set with no members.
The complement of a set A is the set of elements in the image grid G that
are not in A:
Ac
= {w|w ∈ G and w /
∈ A}
DIP Lecture 3 6
Set Operations - Intersection
The operation C = A ∩ B
produces a set that contains
the elements that are in both
A and B.
If A and B are binary image
arrays, then the intersection is
computed in IDL by
D = A AND B
The pixels in the intersection
can be found by
p = WHERE(A AND B)
Set A Set B
Overlap (red) A ∩ B
DIP Lecture 3 7
Set Operations - Complement
The complement Ac
is the
set of elements that are not
contained in A.
The complement is computed
in IDL by
Ac
= A EQ 0
The pixels in the intersection
can be found by
p = WHERE(A EQ 0)
Set A Set Ac
DIP Lecture 3 8
Set Operations - Difference
The difference of two sets A
and B, denoted by A − B is
A − B = {w|w ∈ A and w /
∈ B}
= A ∩ Bc
The set difference does not
involve subtraction of pixel
values.
The pixels in the set can be
computed by
p = WHERE(A AND (B EQ 0))
Set A Set B
Set Bc
A − B
DIP Lecture 3 9
Set Operations - Reflection
A standard morphological operation is the reflection
of all of the points in a set about the origin of the
set. The origin of a set is not necessarily the origin
of the base.
Shown at the right is an image and its reflection
about a point (shown in red), with the original image
in green and the reflected image in white.
SetA
Set Â
DIP Lecture 3 10
Set Operations - Reflection
The reflected image (white) may fall partially or
entirely outside the image grid as shown in the top
figure.
The reflected image (white) may overlap the original
image (green) as shown in the lower figure. The
overlap is blue.
DIP Lecture 3 11
Set Operations - Reflection Program
FUNCTION REFLECTION,k,kc,ncols,nrows,row=row,column=column
;+
;khat=REFLECTION(k,kc,ncols,nrows) is the reflection of image set k
;about the origin represented by kc. The number of columns and rows in the
;base image must be provided. Keywords /row and /column may be set to
;reflect the image around the row or column that contains kc instead of the point
;kc.
;
;If the reflected set is empty then khat=-1 is returned.
;
;HISTORY
;Default reflection written by HR Sept. 1999 for SIMG-782
;Modified to reflect about row and column by JH Oct. 2000 for SIMG-782
;-
IF N PARAMS() LT 4 THEN MESSAGE,’REFLECTION has too few arguments’
;Find the rectangular coordinats of the set points and the origin.
x=k MOD ncols
y=k/ncols
xc=kc MOD ncols
yc=kc/ncols
DIP Lecture 3 12
Set Operations - Reflection Program (cont)
;Check for keyword specifying desired reflection and then carry that reflection out.
if keyword set(row) then begin
;Doing row reflection
xr=x
yr=2*yc-y
endif else begin
if keyword set(column) then begin
;Doing column reflction
xr=2*xc-x
yr=y
endif else begin
;Reflect about the origin. If x=xc + dx then xr=xc-dx=2*xc-x.
;Same for yr.
xr=2*xc-x
yr=2*yc-y
endelse
endelse
;Keep the points that fall within the base image frame.
is=WHERE(xr GE 0 AND xr LT ncols AND yr GE 0 and yr LT nrows)
if min(is) ge 0 then khat=yr[is]*ncols+xr[is] else khat=-1
RETURN,khat
END
DIP Lecture 3 13
Dilation and Erosion
Dilation and erosion are basic morphological processing operations. They
are defined in terms of more elementary set operations, but are employed
as the basic elements of many algorithms.
Both dilation and erosion are produced by the interaction of a set called a
structuring element with a set of pixels of interest in the image.
The structuring element has both a shape and an origin.
Let A be a set of pixels and let B be a structuring element. Let (B̂)s be
the reflection of B about its origin and followed by a shift by s. Dilation,
written A ⊕ B, is the set of all shifts that satisfy the following:
A ⊕ B = {s|(B̂)s ∩ A 6= ∅}
Equivalently,
A ⊕ B = {s|

(B̂)s ∩ A

⊆ A}
DIP Lecture 3 14
Morphological Dilation
Any pixel in the output image
touched by the · in the structuring
element is set to ON when any
point of the structuring element
touches a ON pixel in the original
image.
This tends to close up holes in
an image by expanding the ON
regions. It also makes objects
larger.
Note that the result depends upon
both the shape of the structuring
element and the location of its
origin.
DIP Lecture 3 15
Morphological Erosion
Any pixel in the output
image touched by the · in
the structuring element is
set to ON when every
point of the structuring
element touches a ON
pixel in the original image.
This tends to makes
objects smaller by
removing pixels.
A B = {s|(B)s ⊆ A}
DIP Lecture 3 16
Morphological Erosion + Dilation
The effect of erosion followed by dilation is illustrated below.
DIP Lecture 3 17
Fingerprint Image Cleanup
The use of ERODE + DILATE is illustrated by this example
DIP Lecture 3 18
Boundary Extraction
Let A be an N × M binary image array with the background represented
by the value 0. The goal of boundary extraction is to find the pixels that
are on the boundary of objects in the image.
The boundary pixels are the set β(A) which can be found by
β(A) = A

(A B)c
where B is a 3 × 3 structuring element.
Boundary extraction can be implemented with the IDL statement
B=A AND NOT ERODE(A,B)
DIP Lecture 3 19
Example
Let A be the array
A =






1110111110
1110111110
1111111111
1111111111
1111111111






The object takes up most of the image, with just four background pixels.
Now, erode with a 3 × 3 structuring element. The result is
E = A B =






0000000000
0100011100
0100011100
0111111110
0000000000






DIP Lecture 3 20
Example (cont)
Ec
=






1111111111
1011100011
1011100011
1000000001
1111111111






A =






1110111110
1110111110
1111111111
1111111111
1111111111






β(A) = A

Ec
=






1110111110
1010100010
1011100011
1000000001
1111111111






The boundary β(A) is shown as an image above. As a set, β(A) is a list of
the foreground pixels in the above array.
DIP Lecture 3 21
Example: Lincoln Image
The following program reproduces the example in GW Figure 9.14.
;Demonstration of Boundary Extraction
fname=datapath+’lincoln.png’
A=Read Image(fname,rr,gg,bb)
TVLCT,rr,gg,bb
sa=Size(A,/DIM)
Window,1,Xsize=sa[0],Ysize=2*sa[1]+1
Erase,255
TV,A,0,sa[1]+1
B=Replicate(1b,3,3)
A1=A AND NOT Erode(A,B)
TV,A1  WSHOW
DIP Lecture 3 22
Example: GW Problem 9.17
Extract an object represented by the white box from a
noisy image, represented by the blobs.
Construct a circular structuring element of radius d=15
(shown in lower left corner of the figure)
d=15  B=shift(dist(2*d+1),d,d) LE d
Perform a sequence of erosions and dilations using the
structuring element.
A1=ERODE(A,B)
A2=DILATE(A1,B)
A3=DILATE(A2,B)
A4=ERODE(A3,B)
DIP Lecture 3 23
GW Problem 9.17 (cont)
A1=ERODE(A,B) A2=DILATE(A1,B) A3=DILATE(A2,B) A4=ERODE(A3,B)
The algorithm does a reasonable job of extracting the object.
However, note the rounded corners and small bumps on the
sides of image A4. Compare to the original shown on the right.
Original Image
DIP Lecture 3 24
GW Problem 9.17 (cont)
A1=ERODE(A,B) A2=DILATE(A1,B) A3=DILATE(A2,B) A4=ERODE(A3,B)
Using a square structuring element of size 31x31 is an
improvement. The white rectangle is now recovered perfectly.
Original Image
DIP Lecture 3 25
Region Filling
Develop an algorithm to fill in bounded regions of background color.
1. Let B be a structuring element of type N4, Nd or N8, depending on the
desired connectivity.
2. Select a pixel p inside a background color region.
3. Initialize X0 to be an array of background pixels except X0[p] = 1.
4. Perform the iteration
Xk = (Xk−1 ⊕ B)

Ac
for k = 1, 2, 3, . . .
until Xk = Xk−1.
DIP Lecture 3 26
Region Filling Program
Function Region Fill,A,start,filter=B,max iterations=max iterations
IF n params() LT 2 THEN Message,’Too Few Arguments to Function’
IF NOT KEYWORD SET(B) THEN B=[[0b,1b,0b],[1b,1b,1b],[0b,1b,0b]]
IF NOT KEYWORD SET(max iterations) THEN max iterations=10000L
sa=Size(A,/dim)
X=BytArr(sa[0],sa[1])  X[start]=1b
Y=BytArr(sa[0],sa[1])
Ac=A EQ 0
count=0
WHILE ((min(X EQ Y) EQ 0) AND (count LT max iterations)) DO BEGIN
count=count+1
Y=X
X=Dilate(Y,B) AND Ac
ENDWHILE
RETURN,X
END
DIP Lecture 3 27
Example: Connected Regions in Maze
DIP Lecture 3 28
Example: Connected Regions in Maze
DIP Lecture 3 29

Contenu connexe

Similaire à Morphological image processing.pdf

Morphological image processing
Morphological image processingMorphological image processing
Morphological image processingRaghu Kumar
 
Fin500J_MatrixAlgebra_2011.ppt
Fin500J_MatrixAlgebra_2011.pptFin500J_MatrixAlgebra_2011.ppt
Fin500J_MatrixAlgebra_2011.pptAMNA487167
 
module 1Final flat FLAT Notes-1-101.pptx
module 1Final  flat FLAT Notes-1-101.pptxmodule 1Final  flat FLAT Notes-1-101.pptx
module 1Final flat FLAT Notes-1-101.pptxSrinivasRedyySarviga
 
morphological image processing
morphological image processingmorphological image processing
morphological image processingJohn Williams
 
Application of Graph Theory in Computer science using Data Structure.pdf
Application of Graph Theory in Computer science using Data Structure.pdfApplication of Graph Theory in Computer science using Data Structure.pdf
Application of Graph Theory in Computer science using Data Structure.pdfNancy Ideker
 
Exponential-Function.pptx general Mathematics
Exponential-Function.pptx general MathematicsExponential-Function.pptx general Mathematics
Exponential-Function.pptx general MathematicsPrinCess534001
 
Morphological Image Processing
Morphological Image ProcessingMorphological Image Processing
Morphological Image Processingkumari36
 
KARNAUGH MAP(K-MAP)
KARNAUGH MAP(K-MAP)KARNAUGH MAP(K-MAP)
KARNAUGH MAP(K-MAP)mihir jain
 
Ayush Jajoo(MCA2501622) AOA .pptx
Ayush Jajoo(MCA2501622) AOA .pptxAyush Jajoo(MCA2501622) AOA .pptx
Ayush Jajoo(MCA2501622) AOA .pptxAmanChoudhary329978
 
Answers Of Discrete Mathematics
Answers Of Discrete MathematicsAnswers Of Discrete Mathematics
Answers Of Discrete MathematicsSabrina Green
 
JEE+Crash+course+_+Phase+I+_+Session+1+_+Sets+and++Relations+&+Functions+_+7t...
JEE+Crash+course+_+Phase+I+_+Session+1+_+Sets+and++Relations+&+Functions+_+7t...JEE+Crash+course+_+Phase+I+_+Session+1+_+Sets+and++Relations+&+Functions+_+7t...
JEE+Crash+course+_+Phase+I+_+Session+1+_+Sets+and++Relations+&+Functions+_+7t...7anantsharma7
 
venndiagram.pdf
venndiagram.pdfvenndiagram.pdf
venndiagram.pdfFrenxy1
 

Similaire à Morphological image processing.pdf (20)

Chap4
Chap4Chap4
Chap4
 
F4 03 Sets
F4 03 SetsF4 03 Sets
F4 03 Sets
 
Morphological image processing
Morphological image processingMorphological image processing
Morphological image processing
 
Matrix Algebra
Matrix Algebra Matrix Algebra
Matrix Algebra
 
Mtk3013 chapter 2-3
Mtk3013   chapter 2-3Mtk3013   chapter 2-3
Mtk3013 chapter 2-3
 
Fin500J_MatrixAlgebra_2011.ppt
Fin500J_MatrixAlgebra_2011.pptFin500J_MatrixAlgebra_2011.ppt
Fin500J_MatrixAlgebra_2011.ppt
 
module 1Final flat FLAT Notes-1-101.pptx
module 1Final  flat FLAT Notes-1-101.pptxmodule 1Final  flat FLAT Notes-1-101.pptx
module 1Final flat FLAT Notes-1-101.pptx
 
Sets
SetsSets
Sets
 
morphological image processing
morphological image processingmorphological image processing
morphological image processing
 
Application of Graph Theory in Computer science using Data Structure.pdf
Application of Graph Theory in Computer science using Data Structure.pdfApplication of Graph Theory in Computer science using Data Structure.pdf
Application of Graph Theory in Computer science using Data Structure.pdf
 
Exponential-Function.pptx general Mathematics
Exponential-Function.pptx general MathematicsExponential-Function.pptx general Mathematics
Exponential-Function.pptx general Mathematics
 
Morphological Image Processing
Morphological Image ProcessingMorphological Image Processing
Morphological Image Processing
 
CVGIP_Chia-Pin Tseng
CVGIP_Chia-Pin TsengCVGIP_Chia-Pin Tseng
CVGIP_Chia-Pin Tseng
 
KARNAUGH MAP(K-MAP)
KARNAUGH MAP(K-MAP)KARNAUGH MAP(K-MAP)
KARNAUGH MAP(K-MAP)
 
Ch01-2.ppt
Ch01-2.pptCh01-2.ppt
Ch01-2.ppt
 
Ayush Jajoo(MCA2501622) AOA .pptx
Ayush Jajoo(MCA2501622) AOA .pptxAyush Jajoo(MCA2501622) AOA .pptx
Ayush Jajoo(MCA2501622) AOA .pptx
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Answers Of Discrete Mathematics
Answers Of Discrete MathematicsAnswers Of Discrete Mathematics
Answers Of Discrete Mathematics
 
JEE+Crash+course+_+Phase+I+_+Session+1+_+Sets+and++Relations+&+Functions+_+7t...
JEE+Crash+course+_+Phase+I+_+Session+1+_+Sets+and++Relations+&+Functions+_+7t...JEE+Crash+course+_+Phase+I+_+Session+1+_+Sets+and++Relations+&+Functions+_+7t...
JEE+Crash+course+_+Phase+I+_+Session+1+_+Sets+and++Relations+&+Functions+_+7t...
 
venndiagram.pdf
venndiagram.pdfvenndiagram.pdf
venndiagram.pdf
 

Dernier

Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...SUHANI PANDEY
 
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...kajalverma014
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...tanu pandey
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...Neha Pandey
 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...roncy bisnoi
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...tanu pandey
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"growthgrids
 
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...SUHANI PANDEY
 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...SUHANI PANDEY
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...nirzagarg
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdfMatthew Sinclair
 
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋nirzagarg
 
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...tanu pandey
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirtrahman018755
 
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...SUHANI PANDEY
 

Dernier (20)

Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
 
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
 
Thalassery Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call G...
Thalassery Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call G...Thalassery Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call G...
Thalassery Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call G...
 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
 
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
 
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
 

Morphological image processing.pdf

  • 1. Lecture 3: Basic Morphological Image Processing Harvey Rhody Chester F. Carlson Center for Imaging Science Rochester Institute of Technology rhody@cis.rit.edu September 13, 2005 Abstract Morphological processing is constructed with operations on sets of pixels. Binary morphology uses only set membership and is indifferent to the value, such as gray level or color, of a pixel. We will examine some basic set operations and their usefulness in image processing. DIP Lecture 3
  • 2. Morphology and Sets We will deal here only with morphological operations for binary images. This will provide a basic understanding of the techniques. Morphological processing for gray scale images requires more sophisticated mathematical development. Morphological processing is described almost entirely as operations on sets. In this discussion, a set is a collection of pixels in the context of an image. Our sets will be collections of points on an image grid G of size N × M pixels. DIP Lecture 3 1
  • 3. Pixel Location A set A of pixels in G can be described by giving a list of the pixel locations. The locations can be given as a list of index positions from G that are included in A. If G is of size N × M then the index positions are the integers in the range [0, MN − 1]. For [N, M] = [7, 3] the index grid is G = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 A pixel in column x and row y has index p = x + Ny. Given p one can find the column and row coordinates by x = p mod N y = p/N DIP Lecture 3 2
  • 4. Set Operations Let A and B be sets. If a is the index of a pixel in A, then we write a ∈ A. If a is not in A we write a / ∈ A. If every element that is in A is also in B then A is a subset of B, written A ⊆ B This is equivalent to the statement a ∈ A ⇒ a ∈ B. The union of A and B is the collection of all elements that are in one or both set. The union is the set represented by C = A ∪ B. We can write C = {p|p ∈ A or p ∈ B (or both)} DIP Lecture 3 3
  • 5. Set Operations Set A is the white object in the black box on the right. The image grid G is the N ×M black rectangle that holds the set. In IDL programs we write a set A as an array whose background values are zero and object values are not zero. We can find the coordinates of the object by p = WHERE(A) x = p mod N y = p/N DIP Lecture 3 4
  • 6. Set Operations - Union The operation C = A ∪ B produces a set that contains the elements of both A and B. The fact that some elements are represented in both sets (red pixels) does not affect the result. Note that B itself contains two disjoint subsets. Set A Set B Overlap (red) A ∪ B DIP Lecture 3 5
  • 7. Set Operations (cont) The intersection of two sets A and B is D = A ∩ B = {p|p ∈ A and p ∈ B} It is possible that A and B have no common elements. In that case, we say that they are disjoint and write A ∩ B = ∅ where ∅ is the name for the set with no members. The complement of a set A is the set of elements in the image grid G that are not in A: Ac = {w|w ∈ G and w / ∈ A} DIP Lecture 3 6
  • 8. Set Operations - Intersection The operation C = A ∩ B produces a set that contains the elements that are in both A and B. If A and B are binary image arrays, then the intersection is computed in IDL by D = A AND B The pixels in the intersection can be found by p = WHERE(A AND B) Set A Set B Overlap (red) A ∩ B DIP Lecture 3 7
  • 9. Set Operations - Complement The complement Ac is the set of elements that are not contained in A. The complement is computed in IDL by Ac = A EQ 0 The pixels in the intersection can be found by p = WHERE(A EQ 0) Set A Set Ac DIP Lecture 3 8
  • 10. Set Operations - Difference The difference of two sets A and B, denoted by A − B is A − B = {w|w ∈ A and w / ∈ B} = A ∩ Bc The set difference does not involve subtraction of pixel values. The pixels in the set can be computed by p = WHERE(A AND (B EQ 0)) Set A Set B Set Bc A − B DIP Lecture 3 9
  • 11. Set Operations - Reflection A standard morphological operation is the reflection of all of the points in a set about the origin of the set. The origin of a set is not necessarily the origin of the base. Shown at the right is an image and its reflection about a point (shown in red), with the original image in green and the reflected image in white. SetA Set  DIP Lecture 3 10
  • 12. Set Operations - Reflection The reflected image (white) may fall partially or entirely outside the image grid as shown in the top figure. The reflected image (white) may overlap the original image (green) as shown in the lower figure. The overlap is blue. DIP Lecture 3 11
  • 13. Set Operations - Reflection Program FUNCTION REFLECTION,k,kc,ncols,nrows,row=row,column=column ;+ ;khat=REFLECTION(k,kc,ncols,nrows) is the reflection of image set k ;about the origin represented by kc. The number of columns and rows in the ;base image must be provided. Keywords /row and /column may be set to ;reflect the image around the row or column that contains kc instead of the point ;kc. ; ;If the reflected set is empty then khat=-1 is returned. ; ;HISTORY ;Default reflection written by HR Sept. 1999 for SIMG-782 ;Modified to reflect about row and column by JH Oct. 2000 for SIMG-782 ;- IF N PARAMS() LT 4 THEN MESSAGE,’REFLECTION has too few arguments’ ;Find the rectangular coordinats of the set points and the origin. x=k MOD ncols y=k/ncols xc=kc MOD ncols yc=kc/ncols DIP Lecture 3 12
  • 14. Set Operations - Reflection Program (cont) ;Check for keyword specifying desired reflection and then carry that reflection out. if keyword set(row) then begin ;Doing row reflection xr=x yr=2*yc-y endif else begin if keyword set(column) then begin ;Doing column reflction xr=2*xc-x yr=y endif else begin ;Reflect about the origin. If x=xc + dx then xr=xc-dx=2*xc-x. ;Same for yr. xr=2*xc-x yr=2*yc-y endelse endelse ;Keep the points that fall within the base image frame. is=WHERE(xr GE 0 AND xr LT ncols AND yr GE 0 and yr LT nrows) if min(is) ge 0 then khat=yr[is]*ncols+xr[is] else khat=-1 RETURN,khat END DIP Lecture 3 13
  • 15. Dilation and Erosion Dilation and erosion are basic morphological processing operations. They are defined in terms of more elementary set operations, but are employed as the basic elements of many algorithms. Both dilation and erosion are produced by the interaction of a set called a structuring element with a set of pixels of interest in the image. The structuring element has both a shape and an origin. Let A be a set of pixels and let B be a structuring element. Let (B̂)s be the reflection of B about its origin and followed by a shift by s. Dilation, written A ⊕ B, is the set of all shifts that satisfy the following: A ⊕ B = {s|(B̂)s ∩ A 6= ∅} Equivalently, A ⊕ B = {s| (B̂)s ∩ A ⊆ A} DIP Lecture 3 14
  • 16. Morphological Dilation Any pixel in the output image touched by the · in the structuring element is set to ON when any point of the structuring element touches a ON pixel in the original image. This tends to close up holes in an image by expanding the ON regions. It also makes objects larger. Note that the result depends upon both the shape of the structuring element and the location of its origin. DIP Lecture 3 15
  • 17. Morphological Erosion Any pixel in the output image touched by the · in the structuring element is set to ON when every point of the structuring element touches a ON pixel in the original image. This tends to makes objects smaller by removing pixels. A B = {s|(B)s ⊆ A} DIP Lecture 3 16
  • 18. Morphological Erosion + Dilation The effect of erosion followed by dilation is illustrated below. DIP Lecture 3 17
  • 19. Fingerprint Image Cleanup The use of ERODE + DILATE is illustrated by this example DIP Lecture 3 18
  • 20. Boundary Extraction Let A be an N × M binary image array with the background represented by the value 0. The goal of boundary extraction is to find the pixels that are on the boundary of objects in the image. The boundary pixels are the set β(A) which can be found by β(A) = A (A B)c where B is a 3 × 3 structuring element. Boundary extraction can be implemented with the IDL statement B=A AND NOT ERODE(A,B) DIP Lecture 3 19
  • 21. Example Let A be the array A =       1110111110 1110111110 1111111111 1111111111 1111111111       The object takes up most of the image, with just four background pixels. Now, erode with a 3 × 3 structuring element. The result is E = A B =       0000000000 0100011100 0100011100 0111111110 0000000000       DIP Lecture 3 20
  • 22. Example (cont) Ec =       1111111111 1011100011 1011100011 1000000001 1111111111       A =       1110111110 1110111110 1111111111 1111111111 1111111111       β(A) = A Ec =       1110111110 1010100010 1011100011 1000000001 1111111111       The boundary β(A) is shown as an image above. As a set, β(A) is a list of the foreground pixels in the above array. DIP Lecture 3 21
  • 23. Example: Lincoln Image The following program reproduces the example in GW Figure 9.14. ;Demonstration of Boundary Extraction fname=datapath+’lincoln.png’ A=Read Image(fname,rr,gg,bb) TVLCT,rr,gg,bb sa=Size(A,/DIM) Window,1,Xsize=sa[0],Ysize=2*sa[1]+1 Erase,255 TV,A,0,sa[1]+1 B=Replicate(1b,3,3) A1=A AND NOT Erode(A,B) TV,A1 WSHOW DIP Lecture 3 22
  • 24. Example: GW Problem 9.17 Extract an object represented by the white box from a noisy image, represented by the blobs. Construct a circular structuring element of radius d=15 (shown in lower left corner of the figure) d=15 B=shift(dist(2*d+1),d,d) LE d Perform a sequence of erosions and dilations using the structuring element. A1=ERODE(A,B) A2=DILATE(A1,B) A3=DILATE(A2,B) A4=ERODE(A3,B) DIP Lecture 3 23
  • 25. GW Problem 9.17 (cont) A1=ERODE(A,B) A2=DILATE(A1,B) A3=DILATE(A2,B) A4=ERODE(A3,B) The algorithm does a reasonable job of extracting the object. However, note the rounded corners and small bumps on the sides of image A4. Compare to the original shown on the right. Original Image DIP Lecture 3 24
  • 26. GW Problem 9.17 (cont) A1=ERODE(A,B) A2=DILATE(A1,B) A3=DILATE(A2,B) A4=ERODE(A3,B) Using a square structuring element of size 31x31 is an improvement. The white rectangle is now recovered perfectly. Original Image DIP Lecture 3 25
  • 27. Region Filling Develop an algorithm to fill in bounded regions of background color. 1. Let B be a structuring element of type N4, Nd or N8, depending on the desired connectivity. 2. Select a pixel p inside a background color region. 3. Initialize X0 to be an array of background pixels except X0[p] = 1. 4. Perform the iteration Xk = (Xk−1 ⊕ B) Ac for k = 1, 2, 3, . . . until Xk = Xk−1. DIP Lecture 3 26
  • 28. Region Filling Program Function Region Fill,A,start,filter=B,max iterations=max iterations IF n params() LT 2 THEN Message,’Too Few Arguments to Function’ IF NOT KEYWORD SET(B) THEN B=[[0b,1b,0b],[1b,1b,1b],[0b,1b,0b]] IF NOT KEYWORD SET(max iterations) THEN max iterations=10000L sa=Size(A,/dim) X=BytArr(sa[0],sa[1]) X[start]=1b Y=BytArr(sa[0],sa[1]) Ac=A EQ 0 count=0 WHILE ((min(X EQ Y) EQ 0) AND (count LT max iterations)) DO BEGIN count=count+1 Y=X X=Dilate(Y,B) AND Ac ENDWHILE RETURN,X END DIP Lecture 3 27
  • 29. Example: Connected Regions in Maze DIP Lecture 3 28
  • 30. Example: Connected Regions in Maze DIP Lecture 3 29