Top Banner
Einführung in Visual Computing Unit 18: Morphological Operations Content: Introduction Structuring Element Erosion Dilation Opening Closing HitandMiss Thinning http://www.caa.tuwien.ac.at/cvl/teaching/sommersemester/evc 1 Robert Sablatnig, Computer Vision Lab, EVC18: Morphological Operations
87

Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Nov 01, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Einführung in Visual Computing Unit 18: Morphological Operations 

Content: Introduction Structuring Element Erosion Dilation Opening Closing Hit‐and‐Miss Thinning

http://www.caa.tuwien.ac.at/cvl/teaching/sommersemester/evc

1 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 2: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Introduction

Morphology denotes branch of biology that deals with form and structure of animals and plants.

Same word in the context of Mathematical Morphology: Tool  for extracting image components that are useful in representation and description of region shape, such as boundaries, skeletons etc.

Language of Mathematical Morphology is set theory.

Sets in Mathematical Morphology represent objects in image. 

Motive: Extract features from shape

2 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 3: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Introduction

Morph means “Shape”

We do Morphology for Shape Analysis & Shape Study.

Shape analysis easy in case of binary images, pixel locations describe the shape.

Digital Morphology is a way to describe or analyze the shape of objects in digital images

3 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 4: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Introduction

Value of each pixel in the output image is based on a comparisonof the corresponding pixel in the input image with its neighbors.

By choosing size and shape of neighborhood, you can construct a morphological operation that is sensitive to specific shapes in the input image.

Morphologic operations are especially suited to the processing of binary and greyscale images.

Good for, e.g., Noise removal in background Removal of holes in foreground / background

4 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 5: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Basic Concepts From Set Theory

.B xandA x|xBA B, andA of difference The

.Ax|xA A, of complement The.B xandA x|xBA B, andA ofon intersecti The

.Bor xA x|xBA B, andA ofunion The.Ba A,aevery for if B,A written B, ofsubset a isA

A.a A write ofelement an not is a indicate To A.a A write ofelement an is a indicate To

sets. be B andA Let

c

5 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 6: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

A

B

A

B

B

A

A

B

BA BA

cA cBABA

A

Examples

6 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 7: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Dilation and Erosion

Dilation and Erosion are the two fundamentalmorphological operations.

Dilation adds pixels to the boundaries of objects in an image, while erosion removes pixels on object boundaries. 

In morphological dilation and erosion operations, the state of any given pixel in the output image is determined by applying a rule to the corresponding pixel and its neighbors in the input image. 

The rule used to process the pixels defines the operation as Dilation or Erosion. 

7 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 8: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

A first Example: Erosion

Erosion is an important morphological operation

Applied Structuring Element:

8 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 9: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Example for Erosion

1 0 0 0 1 1 1 0 1 1Input image

Structuring Element

0Output Image

111

9 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 10: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Example for Erosion

1 0 0 0 1 1 1 0 1 1

0 0

111

Input image

Structuring Element

Output Image

10 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 11: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Example for Erosion

1 0 0 0 1 1 1 0 1 1

0 0 0

111

Input image

Structuring Element

Output Image

11 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 12: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Example for Erosion

1 0 0 0 1 1 1 0 1 1

0 0 0 0

111

Input image

Structuring Element

Output Image

12 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 13: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Example for Erosion

1 0 0 0 1 1 1 0 1 1

0 0 0 0 1

111

Input image

Structuring Element

Output Image

13 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 14: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Example for Erosion

1 0 0 0 1 1 1 0 1 1

0 0 0 0 1 0

111

Input image

Structuring Element

Output Image

14 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 15: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Example for Erosion

1 0 0 0 1 1 1 0 1 1

0 0 0 0 1 0 0

111

Input image

Structuring Element

Output Image

15 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 16: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Example for Erosion

1 0 0 0 1 1 1 0 1 1

0 0 0 0 1 0 0 0

111

Input image

Structuring Element

Output Image

16 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 17: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Dilation & Erosion

Basic operations

Are dual to each other: Erosion shrinks foreground, enlarges Background

Dilation enlarges foreground, shrinks background

17 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 18: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Structuring Element

Page 19: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Structuring Element

Essential part of morphological operations is the Structuring Element used to probe the input image. 

Two‐dimensional structuring elements consist of a matrix of 0’s and 1’s, much smaller than the image being processed. 

Structuring Elements can have varyingsizes

Element values are 0,1 and none (!) Structural Elements have origin (anchor pixel)

19 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 20: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Structuring Elements

The center pixel of the structuring element, called the origin, identifies the pixel of interest—the pixel being processed.

The pixels in the structuring element containing 1’s define the neighborhood of the structuring element. 

20 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 21: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Example of Structuring Elements (Kernels)

Empty spots in the Structuring Elements are don’t care’s!

Box

Disc

21 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 22: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Erosion

Page 23: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Erosion

Erosion is the set of all points in the image, where the structuringelement “fits into”.

Consider each foreground pixel in the input image If the structuring element fits in, write a “1” at the origin of the structuring element!

Simple application of pattern matching Input: Binary Image (Gray value) Structuring Element, containing only 1s!

23 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 24: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Erosion

Brief Description To delete or to reduce something Pixels matching a given pattern are deleted from the image. Basic effect 

Erode away the boundaries of regions of foreground pixels (i.e. white pixels, typically).

Common names: Erode, Shrink, Reduce

24 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 25: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Erosion

How It Works A & B are sets in Z², the erosion of A by B, denoted as

In words, this equation indicates that the erosion of A by B is the set of all points z such that B, translated by z, is contained in A. 

BA

ABzBA z )(

25 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 26: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Erosion

Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations26

A 3×3 square structuring element

Set of coordinate points ={ (‐1, ‐1), (0, ‐1), (1, ‐1),(‐1,  0), (0,  0), (1,  0),(‐1,  1), (0,  1), (1,  1) }

Effect of erosion using a 3×3 square structuring element 

Page 27: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Erosion

Erosion By a Rectangular Structuring Element

A

B

BA

27 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 28: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Another Example of Erosion

White = 0, black = 1, dual property, image as a result of erosion gets darker

28 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 29: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Matlab Programming: Erosion

%Read imageI = imread(‘ford.tiff');

figure('Name', 'original');imshow(I);

%create structuring elements% 11‐by‐11 squarese1 = strel('square',11);      

%Apply erosion operationfigure('Name', 'Erode');Ierode1 = imerode(I,se1);

%Show the result imagesubplot(1,1,1), imshow(Ierode1), title('11x11 square');

29 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 30: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Iterative Operation of Erosion

Original Image after 1 erosion

after 5 erosions after inf erosions

30 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 31: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Counting Coins

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

31 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 32: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Dilation

Page 33: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Dilation

Dilation is the set of all points in the image, where the structuring element “touches” the foreground.

Consider each pixel in the input image If the structuring element touches the foreground image, write a “1” at the origin of the structuring element!

Input: Binary Image Structuring Element, containing only 1s!!

33 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 34: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Dilation

Brief Description

To expand or to increase something.

Basic effect: Gradually enlarge the boundaries of regions of foreground pixels on a binary image.

Common names: Dilate, Grow, Expand

34 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 35: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Dilation

How It Works: A & B are sets in Z², the dilation of A by B, denoted as  

This equation is based on obtaining the reflection of B about its origin and shifting this reflection by z. 

The dilation of A by B is the set of all displacements z, such that Band A overlap by at least one element. Based on this interpretation the equation can be written as:

BA

AABzBA z )(

35 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 36: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Dilation

Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations36

Effect of dilation using a 3×3 square structuring element 

3×3 square structuring element

Set of coordinate points ={ (‐1, ‐1), (0, ‐1), (1, ‐1),(‐1,  0), (0,  0), (1,  0),(‐1,  1), (0,  1), (1,  1) }

Page 37: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Example for Dilation

1 0 0 0 1 1 1 0 1 1

1

111

Input image

Structuring Element

Output Image

37 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 38: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Example for Dilation

1 0 0 0 1 1 1 0 1 1

1 0

111

Input image

Structuring Element

Output Image

38 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 39: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Example for Dilation

1 0 0 0 1 1 1 0 1 1

1 0 1

111

Input image

Structuring Element

Output Image

39 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 40: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Example for Dilation

1 0 0 0 1 1 1 0 1 1

1 0 1 1

111

Input image

Structuring Element

Output Image

40 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 41: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Example for Dilation

1 0 0 0 1 1 1 0 1 1

1 0 1 1 1

111

Input image

Structuring Element

Output Image

41 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 42: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Example for Dilation

1 0 0 0 1 1 1 0 1 1

1 0 1 1 1 1

111

Input image

Structuring Element

Output Image

42 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 43: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Example for Dilation

1 0 0 0 1 1 1 0 1 1

1 0 1 1 1 1 1

111

Input image

Structuring Element

Output Image

43 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 44: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Example for Dilation

1 0 0 0 1 1 1 0 1 1

1 0 1 1 1 1 1 1

111

Input image

Structuring Element

Output Image

44 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 45: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Dilation

Example: Binary dilation (Region Filling) Dilation is also used as the basis for other mathematical morphology operators, often in combination with logical operators.

Region filling is a morphological algorithm 

Original image Region filling

45 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 46: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Another Dilation Example

Image get lighter, more uniform intensity

46 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 47: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Matlab Programming: Dilation

%Read imageI = imread(‘ford.tiff');

figure('Name', 'original');imshow(I);

%create structuring elements% 11‐by‐11 squarese1 = strel('square',11);      

%Apply dilation operationfigure('Name', 'Dilate');Idilate1 = imdilate(I,se1);

%Show the result imagesubplot(1,1,1), imshow(Idilate1), title('11x11 square');

47 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 48: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Iterative Operation of Dilation

Original Image after 1 dilation

after 5 dilations after inf dilations

48 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 49: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Dilation

Dilation By A Rectangular Structuring Element

Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations49

A

A BA

B

Page 50: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Edge Detection

Edge Detection1. Dilate input image2. Subtract input image from dilated image3. Edges remain!

50 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 51: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Opening

Page 52: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Opening & Closing

Important operations Derived from the fundamental operations  Dilation Erosion

Usually applied to binary images, but gray value images are also possible

Opening and closing are dual operations

52 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 53: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Combining Dilation and Erosion

Morphological Opening Opening is defined as an erosion, followed by a dilation.

Morphological Closing Closing is defined as a dilation, followed by an erosion.

53 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 54: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Opening

Similar to Erosion Spot and noise removal Less destructive

Erosion next Dilation Same structuring element for both operations.

Input: Binary Image Structuring Element, containing only 1s!

54 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 55: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Opening

Take the structuring element and slide it around inside each foreground region.  All pixels which can be covered by the SE with the SE being entirely within the foreground region will be preserved.

All foreground pixels which can not be reached by the structuring element without lapping over the edge of the foreground object will be eroded away!

Opening is idempotent: Repeated application has no further effects!

55 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 56: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Opening

Brief Description Opening tends to “open” small gaps or spaces between touching objects in an image.

Opening is also used to remove noise (Pepper noise). The erosion step in an opening will remove isolated pixels as well as boundaries of object and the dilation step will restore most of the boundary pixels without restoring the noise.

Common names: Opening

56 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 57: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Opening

How It works Opening is defined as an erosion followed by a dilation.

Opening is the dual of closing Opening the foreground pixels with a particular structuring element is equivalent to Closing the background pixels with the same element.

BBABA

57 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 58: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Opening

Structuring element: 3x3 square1 1 1

1 1 1

1 1 1

58 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 59: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Opening

Binary Opening Example Separate out the circles from the lines

The lines have been almost completely removed while the circles remain almost completely unaffected.

A mixture of circle and lines Opening with a disk shaped structuring element with 11 pixels in diameter

59 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 60: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Opening Example

Opening with a 9 pixel diameter disc

Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations60

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

Page 61: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Opening Example

3x9 and 9x3 Structuring Element

3*9

9*3

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

61 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 62: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Opening

Binary Opening Example Extract the horizontal and vertical lines separately

There are a few glitches in rightmost image where the diagonal lines cross vertical lines.

These could easily be eliminated, however, using a slightly longer structuring element.

Original image The result of an Opening with 3×9 vertically oriented structuring element

The result of an Opening with 9×3 horizontally oriented 

structuring element

62 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 63: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Matlab Programming: Opening

%Read imageI = imread(‘ford.tiff');

figure('Name', 'original');imshow(I);

%create structuring elements% 11‐by‐11 squarese1 = strel('square',11);      

%Apply the open oprationfigure('Name', 'Open');Iopen1 = imopen(I,se1);

%Show the result imagesubplot(1,1,1), imshow(Iopen1), title('11x11 square');

63 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 64: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Iterative Operation of Opening

Original Image after 1 opening

after 5 openings after inf openings

64 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 65: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Use Opening for Separating Blobs

Use large structuring element that fits into the big blobs Structuring Element: 11 pixel disc

65 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 66: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Closing

Page 67: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Closing

Similar to Dilation Removal of holes Tends to enlarge regions, shrink background

Closing is defined as a Dilatation, followed by an Erosion using the same structuring element for both operations.

Dilation next Erosion!

Input: Binary Image Structuring Element, containing only 1s!

67 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 68: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Closing

Take the structuring element and slide it around outside each foreground region.  All background pixels which can be covered by the SE with the SE being entirely within the background region will be preserved.

All background pixels which can not be reached by the structuring element without lapping over the edge of the foreground object will be turned into a foreground.

Opening is idempotent: Repeated application has no further effects!

68 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 69: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Closing

Structuring element: 3x3 square1 1 1

1 1 1

1 1 1

69 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 70: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Closing Example

Closing operation with a 22 pixel disc Closes small holes in the foreground

70 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 71: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Threshold Closing with disc of size 20

Closing Example

Thresholded closed

71 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 72: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Matlab Programming: Closing

%Read imageI = imread(‘ford.tiff');

figure('Name', 'original');imshow(I);

%create structuring elements% 11‐by‐11 squarese1 = strel('square',11);      

%Apply close operationfigure('Name', ‘Close');Iclose1 = imclose(I,se1);

%Show the result imagesubplot(1,1,1), imshow(Iclose1), title('11x11 square');

Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations72

Page 73: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Iterative Operation of Closing 

Original Image after 1 opening

after 5 openings after inf openings

73 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 74: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Opening & Closing

Opening is the dual of closing  i.e. opening the foreground pixels with a particular structuring element 

is equivalent to closing the background pixels with the same element. 

74 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 75: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Hit and Miss

Page 76: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Hit‐and‐Miss Transform

Used to look for particular patterns of foreground and background pixels

Very simple object recognition All other morphological operations can be derived from it!!

Input:  Binary Image Structuring Element, containing 0s and 1s!!

76 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 77: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Hit‐and‐Miss Transform

How It Works The structuring element used in the hit‐and‐miss can contain bothforeground and background pixels.

OperationsIf the foreground and background pixels in the structuring elementexactly match foreground and background pixels in the image, thenthe pixel underneath the origin of the structuring element is set tothe foreground color.If it doesn't match, then that pixel is set to the background color.

77 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 78: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Hit‐and‐Miss Transform

Effect of the hit‐and‐miss based right angle convex corner detector

Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations78

Four structuring elements used for corner finding in binary images

Page 79: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Hit‐and‐Miss Transform

Guidelines for Use The hit‐and‐miss transform is used to look for occurrences of particular binary patterns.

It can be used to look for several patterns: Simply by running successive transforms using different structuring elements, and then ORing the results together.

The operations of erosion, dilation, opening, closing, thinning and thickening can all be derived from the hit‐and‐miss transform in conjunction with simple set operations.

79 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 80: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Hit‐and‐Miss Transform

Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations80

The triple points (points where three lines meet) of the skeleton

Hit‐and‐miss transform outputs single foreground pixels at each triple point 

Image was dilated once using a cross‐shaped structuring element in order to mark these isolated points clearly, and this was then ORedwith the original skeleton.

Page 81: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Basic Thinning

Page 82: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Thinning

1. Used to remove selected foreground pixels from binary images

2. After edge detection, lines are often thicker than one pixel. 

3. Thinning can be used to thin those line to one pixel width.

82 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 83: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Thinning

Brief Description

Remove selected foreground pixels from binary images, somewhat like erosion or opening.

Thinning is normally applied only to binary images.

Common names: Thinning

83 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 84: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Thinning

Operation Translate origin of the structuring element to each possible pixel position in the image and compare it with the underlying image pixels.

If foreground and background pixels in the structuring element exactly match foreground and background pixels in the image, then the image pixel underneath the origin of the structuring element is set to background (zero).

Otherwise, it is left unchanged.

Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations84

Page 85: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Thinning

Example: Thinning (character recognition) 1) shows the structuring element used in combination with thinning to obtain the skeleton.

2) was used in combination with thinning to prune the skeleton and with the hit‐and‐miss operator to find the end points of the skeleton.

Each structuring element was used in each of its 45°rotations. 

85 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 86: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Thinning

A simple way to obtain the skeleton of the character is to thin the image until convergence.The line is broken at some locations, which might cause problems during the recognition process.

Original image Thresholded image Thinning result

86 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations

Page 87: Unit 18: Morphological Operations - TU Wien...Essential part of morphological operations is the StructuringElement used to probe the input image. Two‐dimensional structuringelements

Example Thinning

We use two Hit‐and‐miss Transforms

87 Robert Sablatnig, Computer Vision Lab, EVC‐18: Morphological Operations