Title: Image Processing
1Image Processing 4Morphology
2Agenda Morphology
- What can it be used for?
- Basic operations
- Fit and hit
- Erosion
- Dilation
- Compound operations
- Examples
3What can it be used for?
- Remove noise
- Small objects
- Fill holes
- Isolate objects
4How does it work?
- Grayscale image
- Threshold gt Binary image
- Morphology
- But also works directly on grayscale images
5Definitions 1D
Input image
Design it as you please
Structuring Element (SE)
Output Image
Hit If just one of the 1s in the SE match with
the input gt output 1, otherwise output
0 Fit If all 1s in the SE match with input gt
output 1, otherwise output 0
6Dilation (based on Hit)
7Example for Dilation
Input image
Structuring Element
Output Image
Hit If just one of the 1s in the SE match with
the input gt output 1, otherwise output 0
8Example for Dilation
Input image
Structuring Element
Output Image
9Example for Dilation
Input image
Structuring Element
Output Image
10Example for Dilation
Input image
Structuring Element
Output Image
11Example for Dilation
Input image
Structuring Element
Output Image
12Example for Dilation
Input image
Structuring Element
Output Image
13Example for Dilation
Input image
Structuring Element
Output Image
14Example for Dilation
Input image
Structuring Element
Output Image
The object gets bigger and holes are filled!
15Erosion (based on Fit)
16Example for Erosion
Input image
Structuring Element
Output Image
Fit If all 1s in the SE match with input gt
output 1, otherwise output 0
_
_
_
17Example for Erosion
Input image
Structuring Element
Output Image
18Example for Erosion
Input image
Structuring Element
Output Image
19Example for Erosion
Input image
Structuring Element
Output Image
20Example for Erosion
Input image
Structuring Element
Output Image
21Example for Erosion
Input image
Structuring Element
Output Image
22Example for Erosion
Input image
Structuring Element
Output Image
23Example for Erosion
Input image
Structuring Element
Output Image
The object gets smaller
24Morphology on images
25Structuring Element (Kernel)
- 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 dont
cares!
Box Disc
262D Dilation (based on Hit)
Structuring element
- Objects are merged (holes are filled)
- Sharp corners are preserved
27Another Dilation Example
Structuring element disc gt rounded corners
( Show Fill holes SE3x3 box, blob-holes.tif )
282D Erosion (based on Fit)
Structuring element
Objects get smaller
29Another erosion example
(Show Remove small objects SEbox, cell_colony)
30Counting Coins
- Counting these coins is difficult because they
touch each other! - Solution Threshold and Erosion separates them!
31Compound operations
- Combining Erosion and Dilation into higher level
(more advanced) operations - Finding the outline
- Opening Isolate objects and remove small objects
(better than Erosion) - Closing Fill holes (better than Dilation)
- Others
32Finding the outline
- Edge Detection
- Dilate input image (object gets bigger)
- Subtract input image from dilated image
- Edges remain!
33Opening
- Motivation Remove small objects BUT keep
original size (and shape) (show cell_colony, 3 x
iteration)
34Opening
- Motivation Remove small objects BUT keep
original size (and shape) (show cell_colony) - Erosion Dilation Opening
- Use the same structuring element!
- Similar to erosion but less destructive
- Math
- Opening is idempotent Repeated operations has no
further effects!
35Opening
Erosion
Dilation
36Opening Example
- 9x3 and 3x9 Structuring Elements
37Opening example
- Size of structuring element should fit into the
smallest object to keep - Structuring Element 11 pixel disc
(show cell_colony, 3 x erosion, 3 x dilation)
38Closing
- Motivation Fill holes BUT keep original size
(and shape) (show blobs-holes, 1 x iteration)
39Closing
- Motivation Fill holes BUT keep original size
(and shape) (show blobs-holes) - Dilation Erosion Closing
- Use the same structuring element!
- Similar to Dilation but less destructive
- Math
- Closing is idempotent Repeated operations has no
further effects!
40Closing
- Structuring element 3x3 square
41Closing Example
- Closing operation with a 22 pixel disc
- Closes small holes
42Closing Example
- Improve segmentation
- Threshold
- Closing with disc of size 20
(show blobs-holes, 1 x dilation, 1 x erosion)
43What to remember
- Morphology
- Fit and Hit operations
- Erosion (based on Fit) Make objects smaller
- Separate objects, remove small objects (noise)
- Dilation (based on Hit) Make objects bigger
- Remove holes in objects
- Finding the outlines of the objects
- Opening (Erosion Dilation)
- As Erosion but less destructive
- Closing (Dilation Erosion)
- As Dilation but less destructive
44Exercises (1/2)
- Discuss the PE-questions
- Solve exercise 1 on page 296 in the book
- Play around with the different morphologic
operations in ImageJ Process gt Binary - Use morphology to improve the result from last
time on the imagedots - Remove the lines in the imagedots-lines
45Exercises (2/2)
- (Re)read about the hit and miss transform
(287-288) and answer the following questions - How can the transform be used to find this type
of corners? - (use 3x3 structuring
- elements)
- How does this relate to
- Template Matching?