image analysis...dtu compute 23 dtu compute, technical university of denmark image analysis 2020 1d...
Post on 22-Jan-2021
1 Views
Preview:
TRANSCRIPT
DTU Compute
Image Analysis
Plenty of slides adapted from Thomas Moeslunds lectures
Rasmus R. Paulsen
Tim B. Dyrby
DTU Compute
rapa@dtu.dk
http://www.compute.dtu.dk/courses/02502
DTU Compute
2021Image Analysis2 DTU Compute, Technical University of Denmark
Lecture 4b – Morphology
0 0 1 1 1 0 0
0 1 1 1 1 1 0
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
0 1 1 1 1 1 0
0 0 1 1 1 0 0
DTU Compute
2021Image Analysis3 DTU Compute, Technical University of Denmark
What can you do after today?
Describe the similarity between filtering and morphology
Describe a structuring element
Compute the dilation of a binary image
Compute the erosion of a binary image
Compute the opening of a binary image
Compute the closing of a binary image
Apply compound morphological operations to binary images
Describe typical examples where morphology is suitable
Remove unwanted elements from binary images using morphology
Choose appropriate structuring elements and morphological operations based on image content
DTU Compute
2021Image Analysis4 DTU Compute, Technical University of Denmark
Morphology
The science of form, shape and structure
In biology: The form and structure of animals and plants
Common leaf morphologies
DTU Compute
2021Image Analysis5 DTU Compute, Technical University of Denmark
Mathematical morphology
Developed in 1964
Theoretical work done in Paris
Used for classification of minerals in cut stone
Initially used for binary images
Do not worry! We use a much less theoretical approach!
DTU Compute
2021Image Analysis6 DTU Compute, Technical University of Denmark
Relevance?
Point wise operations
Filtering
Thresholding
– Gives us objects that are separated by the background
Morphology
– Manipulate and enhance binary objects
DTU Compute
2021Image Analysis7 DTU Compute, Technical University of Denmark
What can it be used for?
Remove noise
– Small objects
– Fill holes
Isolate objects
Customized to specific shapes
DTU Compute
2021Image Analysis8 DTU Compute, Technical University of Denmark
How does it work?
Grayscale image
Preprocessing
– Inversion
Threshold => Binary image
Morphology
DTU Compute
2021Image Analysis9 DTU Compute, Technical University of Denmark
Filtering and morphology
Filtering
– Gray level images
– Kernel
– Moves it over the input image
– Creates a new output image
0 2 4
1 2 2
1 6 3
1 2 1
2 5 3
2 1 3
1 3 1
2 2 2
0 1 3
1 2 0
2 1 4
1 0 1
DTU Compute
2021Image Analysis10 DTU Compute, Technical University of Denmark
Filtering and morphology
Filtering
– Gray level images
– Kernel
– Moves it over the input image
– Creates a new output image
Morphology
– Binary images
– Structuring element (SE)
– Moves the SE over the input image
– Creates a new binary output image
Disk
Box
1
1 11
1
1
1 11
1
1
1
1
1
0
0 0
0
DTU Compute
2021Image Analysis11 DTU Compute, Technical University of Denmark
1D Morphology
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
(SE)
?Output Image
111
DTU Compute
2021Image Analysis12 DTU Compute, Technical University of Denmark
1D Morphology : The hit operation
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
(SE)
?Output Image
111
• If just one 1 in the SE match with the input
• output 1
• else
• output 0
1
DTU Compute
2021Image Analysis13 DTU Compute, Technical University of Denmark
1D Morphology : The fit operation
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
(SE)
?Output Image
111
• If all 1 in the SE match with the input
• output 1
• else
• output 0
0
DTU Compute
2021Image Analysis14 DTU Compute, Technical University of Denmark
1D Morphology : Dilation
Dilate : To make wider or larger
– Dansk : udvide
Based on the hit operation
DTU Compute
2021Image Analysis15 DTU Compute, Technical University of Denmark
1D Dilation example
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
1Output Image
111
• If just one 1 in the SE match with the input
• output 1
• else
• output 0
Hit
to make bigger
𝑔 𝑥 = 𝑓(𝑥)⨁𝑆𝐸
DTU Compute
2021Image Analysis16 DTU Compute, Technical University of Denmark
Example for Dilation
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
1 0Output Image
111
DTU Compute
2021Image Analysis17 DTU Compute, Technical University of Denmark
Example for Dilation
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
1 0 1Output Image
111
DTU Compute
2021Image Analysis18 DTU Compute, Technical University of Denmark
Example for Dilation
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
1 0 1 1Output Image
111
DTU Compute
2021Image Analysis19 DTU Compute, Technical University of Denmark
Example for Dilation
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
1 0 1 1 1Output Image
111
DTU Compute
2021Image Analysis20 DTU Compute, Technical University of Denmark
Example for Dilation
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
1 0 1 1 1 1Output Image
111
DTU Compute
2021Image Analysis21 DTU Compute, Technical University of Denmark
Example for Dilation
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
1 0 1 1 1 1 1Output Image
111
DTU Compute
2021Image Analysis22 DTU Compute, Technical University of Denmark
Example for Dilation
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
1 0 1 1 1 1 1 1Output Image
111
The object gets bigger and holes are filled!
DTU Compute
2021Image Analysis23 DTU Compute, Technical University of Denmark
1D Morphology : Erosion
Erode : To wear down (Waves eroded the shore)
– Dansk : tære, gnave
Based on the fit operation
DTU Compute
2021Image Analysis24 DTU Compute, Technical University of Denmark
Example for Erosion
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
0Output Image
111
12 2 SESE _ _ _
• If all 1 in the SE match with the input
• output 1
• else
• output 0
Fit
to make smaller
𝑔 𝑥 = 𝑓(𝑥)⊖ 𝑆𝐸
DTU Compute
2021Image Analysis25 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis26 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis27 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis28 DTU Compute, Technical University of Denmark
Example for Erosion
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
0 0 0 0 1 0 0 0Output Image
111
The object gets smaller
DTU Compute
2021Image Analysis29 DTU Compute, Technical University of Denmark
Structuring Element (Kernel)
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
Structuring Elements can have varying sizes
Usually, element values are 0 or 1, but other values are possible (including none!)
Structural Elements have an origin
Empty spots in the Structuring Elements are don’t cares!
Disk Box
0 1 0
1 1 1
0 1 0
1 1 1
1 1 1
1 1 1
DTU Compute
2021Image Analysis30 DTU Compute, Technical University of Denmark
Structuring Element Origin
The origin is not always the center of the SE
0 1 0
1 1 1
0 1 0
1 1 1
1 1 1
1 1 1
DTU Compute
2021Image Analysis31 DTU Compute, Technical University of Denmark
Special structuring elements
0 0 0 0 0 1 1
0 0 1 1 1 0 0
1 1 0 0 0 0 0
Structuring elements can be customized to a specific problem
LineDiamond
0 0 0 1 0 0 0
0 0 1 1 1 0 0
0 1 1 1 1 1 0
1 1 1 1 1 1 1
0 1 1 1 1 1 0
0 0 1 1 1 0 0
0 0 0 1 0 0 0
DTU Compute
2021Image Analysis32 DTU Compute, Technical University of Denmark
Dilation on images - diskHoles are closed
SE
Object is bigger𝑔 𝑥, 𝑦 = 𝑓(𝑥, 𝑦)⨁𝑆𝐸
DTU Compute
2021Image Analysis33 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis34 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis35 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis36 DTU Compute, Technical University of Denmark
Dilation – the effect of the SE
DTU Compute
2021Image Analysis37 DTU Compute, Technical University of Denmark
Dilation Example
0 0 1 1 1 0 0
0 1 1 1 1 1 0
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
0 1 1 1 1 1 0
0 0 1 1 1 0 0
• Round structuring element (disk)
• Creates round corners
DTU Compute
2021Image Analysis38 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis39 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis40 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis41 DTU Compute, Technical University of Denmark
Erosion on images - disk
SE
Object is smaller𝑔 𝑥, 𝑦 = 𝑓(𝑥, 𝑦) ⊖ 𝑆𝐸
DTU Compute
2021Image Analysis42 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis43 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis44 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis45 DTU Compute, Technical University of Denmark
Erosion on images – box (square)
SE
1
2
3
4
1
2
3
4
𝑔 𝑥, 𝑦 = 𝑓(𝑥, 𝑦) ⊖ 𝑆𝐸
DTU Compute
2021Image Analysis46 DTU Compute, Technical University of Denmark
Erosion example
DTU Compute
2021Image Analysis47 DTU Compute, Technical University of Denmark
Counting Coins
Counting these coins is difficult because they touch each other!
Solution: Threshold and Erosion separates them!
More on counting next time!
DTU Compute
2021Image Analysis48 DTU Compute, Technical University of Denmark
Compound operations
Compound
– made of two or more separate parts or elements
Combining Erosion and Dilation into more advanced operations
– Finding the outline
– Opening
Isolate objects and remove small objects (better than Erosion)
– Closing
Fill holes (better than Dilation)
DTU Compute
2021Image Analysis49 DTU Compute, Technical University of Denmark
Finding the outline
1. Dilate input image (object gets bigger)
2. Subtract input image from dilated image
3. The outline remains!
𝑔 𝑥, 𝑦 = 𝑓 𝑥, 𝑦 ⨁𝑆𝐸 − 𝑓(𝑥, 𝑦)
DTU Compute
2021Image Analysis50 DTU Compute, Technical University of Denmark
Opening
Motivation: Remove small objects BUT keep original size (and shape)
Opening = Erosion + Dilation
– Use the same structuring element!
– Similar to erosion but less destructive
Math:
Opening is idempotent: Repeated operations has no further effects!
_𝑔 𝑥, 𝑦 = 𝑓 𝑥, 𝑦 ∘ 𝑆𝐸 = (𝑓(𝑥, 𝑦) ⊖ 𝑆𝐸)⊕ 𝑆𝐸
𝑓 𝑥, 𝑦 ∘ 𝑆𝐸 = (𝑓 𝑥, 𝑦 ∘ 𝑆𝐸) ∘ 𝑆𝐸
DTU Compute
2021Image Analysis51 DTU Compute, Technical University of Denmark
Opening
Original Eroded Dilated
SEOpening = erosion+dilation
𝑔 𝑥, 𝑦 = (𝑓(𝑥, 𝑦) ⊖ 𝑆𝐸)⊕ 𝑆𝐸
DTU Compute
2021Image Analysis52 DTU Compute, Technical University of Denmark
Opening Example
9x3 and 3x9 Structuring Elements
DTU Compute
2021Image Analysis53 DTU Compute, Technical University of Denmark
Opening example
Size of structuring element should fit into the smallest object to keep
Structuring Element: 11 pixel disc
DTU Compute
2021Image Analysis54 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis55 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis56 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis57 DTU Compute, Technical University of Denmark
Closing
Motivation: Fill holes BUT keep original size (and shape)
Closing = Dilation + Erosion
– Use the same structuring element!
– Similar to Dilation but less destructive
Math:
Closing is idempotent: Repeated operations has no further effects!
_𝑔 𝑥, 𝑦 = 𝑓 𝑥, 𝑦 𝑆𝐸 = 𝑓 𝑥, 𝑦 ⊕ 𝑆𝐸 ⊖ 𝑆𝐸
𝑓 𝑥, 𝑦 ∘ 𝑆𝐸 = (𝑓 𝑥, 𝑦 ∘ 𝑆𝐸) ∘ 𝑆𝐸
DTU Compute
2021Image Analysis58 DTU Compute, Technical University of Denmark
Closing
Original
SE
Dilated Eroded
Closing = dilation + erosion
𝑔 𝑥, 𝑦 = 𝑓 𝑥, 𝑦 ⊕ 𝑆𝐸 ⊖ 𝑆𝐸
DTU Compute
2021Image Analysis59 DTU Compute, Technical University of Denmark
Closing Example
Closing operation with a 22 pixel disc
Closes small holes
DTU Compute
2021Image Analysis60 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis61 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis62 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis63 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis64 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis65 DTU Compute, Technical University of Denmark
DTU Compute
2021Image Analysis66 DTU Compute, Technical University of Denmark
Next week: Blob Analysis and object classification
top related