程序代写代做代考 matlab CMP 3108, IMAGE PROCESSING LECTURE 6

CMP 3108, IMAGE PROCESSING LECTURE 6
MORPHOLOGY IMAGE PROCESSING
Dr Xujiong Ye
Lincoln School of Computer Science

InterpolaIon
Enhancement-1
Histogram Processing
Enhancement-2
Sharpening (Sobel & Laplacian)
Image Analysis
Syllabus
Fundamentals
Introduc?on Module IntroducIon, Origins of Image Processing (Imaging), Imaging ModaliIes
Image FormaIon, Pixels, SpaIal & Intensity ResoluIons, Grey Level TransformaIons: Contrast Stretching,
SpaIal Filtering: Smoothing (Averaging, Median),
Morphological Image Processing Image Segmenta?on
Applica?ons
Colour Image Processing
Image Compression Representa?on and Descrip?on Real-world Applica?ons
Image Acquisi?on

Mathematical Morphology
• Techniques for pre- or post-processing:
• noise filtering,
• Filling in small holes in foreground,
• extracting connected components,
• Eliminating small protrusions from their boundaries, etc
• Representation and description of region shape:
• boundaries,
• skeletons, etc
CMP3108: Lecture 6 – Morphological Image Processing

Binary Images
CMP3108: Lecture 6 – Morphological Image Processing

Recap: Set Theory
Let A be a set in Z2
a=(a1,a2) is an element in A ⇔ a∈A
a=(a1,a2) is not an element in A ⇔ a∉A
empty set: ∅
set specified using { }, e.g., C={w|w=-d, for d∈D}
reads ”C is the set of elements w such that w = -d, for d element of D”
every element in A is also in B (subset): A⊆B CMP3108: Lecture 6 – Morphological Image Processing

union of A and B: C=A∪B={c|c∈A or c∈B}
Set Theory
A∪B
intersection of A and B: C=A∩B={c|c∈A and c∈B}
disjoint/mutually exclusive: A∩B=∅ CMP3108: Lecture 6 – Morphological Image Processing
A∩B

Set Theory
complement of A: AC={w|w∉A}
AC
difference of A and B: A–B={w|w∈A,w∉B}=A∩BC
A–B
CMP3108: Lecture 6 – Morphological Image Processing

Set Theory
CMP3108: Lecture 6 – Morphological Image Processing

Set Theory
reflection of A: ˆ
A={w|w=−a, for a∈A}
A

translation of A: (A)z={w|w=a+z, for a∈A}
A
(A) z
CMP3108: Lecture 6 – Morphological Image Processing

Neighbourhood Relations
• a pixel has 4 or 8 neighbours in 2D depending on the neighbour definition:
• 4-neighborhood N4(p) each neighbour must share an edge with the pixel
• ND(p) includes diagonal neighbours of p
• 8- neighbourhood N8(p)
each neighbour must share
an edge or a corner with the pixel
CMP3108: Lecture 6 – Morphological Image Processing

Mathematical Morphology
• Basic morphological operators take as input: • Original (binary) image
• Structuring element (SE)
• Basic concepts:
• Erosion and dilation • Opening and closing
CMP3108: Lecture 6 – Morphological Image Processing

Structuring Element
• Structuring Element can have varying size • Defined by an origin and its shape and
size
Box Disc
CMP3108: Lecture 6 – Morphological Image Processing

Morphology Opera?ons
• Erosion
• EliminaIon of boundary pixels from objects in
binary images
• Making objects smaller, also called shrinking
• Dila?on
• Each background pixel that has a neighbor in the
object is relabeled as an object pixel
• Making object bigger, also called growing

Example for Erosion
Does the structuring element fit inside the object?
Input image Structuring Element
Output Image
1
0
0
0
1
1
1
0
1
1
1
1
1
0
CMP3108: Lecture 7 – Morphological Image Processing

Example for Erosion
1
0
0
0
1
1
1
0
1
1
Input image Structuring Element
Output Image
1
1
1
0
0
CMP3108: Lecture 6 – Morphological Image Processing

Example for Erosion
1
0
0
0
1
1
1
0
1
1
Input image Structuring Element
Output Image
1
1
1
0
0
0
CMP3108: Lecture 6 – Morphological Image Processing

Example for Erosion
1
0
0
0
1
1
1
0
1
1
Input image Structuring Element
Output Image
1
1
1
0
0
0
0
CMP3108: Lecture 6 – Morphological Image Processing

Example for Erosion
1
0
0
0
1
1
1
0
1
1
Input image Structuring Element
Output Image
1
1
1
0
0
0
0
1
CMP3108: Lecture 6 – Morphological Image processing

Example for Erosion
1
0
0
0
1
1
1
0
1
1
Input image Structuring Element
Output Image
1
1
1
0
0
0
0
1
0
CMP3108: Lecture 6 – Morphological Image Processing

Example for Erosion
1
0
0
0
1
1
1
0
1
1
Input image Structuring Element
Output Image
1
1
1
0
0
0
0
1
0
0
CMP3108: Lecture 6 – Morphological Image Processing

Example for Erosion
1
0
0
0
1
1
1
0
1
1
Input image Structuring Element
Output Image
1
1
1
0
0
0
0
1
0
0
0
CMP3108: Lecture 6 – Morphological Image Processing

Example: Erosion
• Does the structuring element fit inside the object?
CMP3108: Lecture 6 – Morphological Image Processing
pixels in output image if check is: SE fits

Erosion (⊖) Does the SE (set B)
fit into the set A? • shrinks objects
Erosion of A by B (SE):
all z such that B translated
by z is contained in A
(i.e. the origin of B is at z)
A−B={z|(B)z ⊆A}
B

Different SE, Erosion

Different Structuring Elements, Erosion
25

Counting Coins
• Counting coins is difficult because they touch each other!
• Solution: Binarization and Erosion separates them!

Dilation (⊕) Does the reflection of SE (set B)
touch the set A? • grows objects
Dilation of A by B (SE): all z such that reflection
of B hits A when B
B Bˆ
is translated by z
(i.e. the origin of B is at z)
or
ˆ A⊕B={z|(B)z ∩A⊆A}
ˆ A⊕B={z|(B)z ∩A≠∅}

Basic Morphological Operators
• Different Structuring Elements, Dilation

Different SE, Dilation

Dilation – example

Basic Morphological Operators
• Dilation
• bridging gaps
• Erosion
• eliminating small details
• Structuring Element
• specifies the structure of elements …
• … that are removed by erosion • … that are filled by dilation
B

Basic Morphological Operators
Matlab IPT FuncIon:
• Erosion
A1= imerode (A,B)
• DilaIon
A2= imdilate(A,B)

Opening (∘) • Erosion followed by Dilation
A  B ≡ (A − B )⊕ B
• smoothes foreground objects • breaks “narrow” links
• eliminates “thin” protrusions

Closing (•) • Dilation followed by Erosion
A • B ≡ (A ⊕ B ) − B
• smoothes with respect to the background • close “narrow” breaks
• eliminates “small” holes
2

Opening and Closing
opening of A
closing of A
A

CMP3641M, CV, Lecture 3 – SpaIal Filtering I 36

Basic Morphological Operators
Matlab IPT FuncIon:
• Opening
A1= imopen (A,B)
• DilaIon
A2= imclose(A,B)

Application: noise removal
Original Image

Application: noise removal
1. erode A⊖B
2. dilate
(A⊖B) ⊕ B = A∘B
Opening

Application: noise removal
3. dilate (A∘B)⊕B
4. erode ((A∘B)⊕B)⊖B= (A∘B)•B
Closing

Recommended Reading
“Digital Image Processing”, R.C. Gonzalez and R.E. Woods, 3rd ediIon, Pearson PrenIce Hall, 2008
Chapter 9

Thank you!
42