Digital Image Processing - Sharif University of...

52
Digital Image Processing MORPHOLOGICAL Hamid R. Rabiee Fall 2015

Transcript of Digital Image Processing - Sharif University of...

Page 1: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Digital Image Processing

MORPHOLOGICAL

Hamid R. Rabiee

Fall 2015

Page 2: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Image Analysis

Morphological Image Processing

Edge Detection

Keypoint Detection

Image Feature Extraction

Texture Image Analysis

Shape Analysis

Color Image Processing

Template Matching

Image Segmentation

2

Page 3: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Image Analysis 3

Figure 9.1 of Jain book

Page 4: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Image Analysis

Ultimate aim of image processing applications:

Automatic description, interpretation, or understanding the scene

For example, an image understanding system should be able to send the report:

The field of view contains a dirt road surrounded by grass.

4

Page 5: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Image Analysis 5

Table 9.1 of Jain book

Page 6: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Image Analysis 6

Morphological Analysis Edge Detection Keypoint Detection

original binary

erosion dilation

opening closing

Page 7: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Morphological Image Processing

(MIP)

7

Page 8: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Outline

Preview

Preliminaries

Dilation

Erosion

Opening

Closing

Hit-or-miss transformation

8

Page 9: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Outline (cont.)

Morphological algorithms

Boundary Extraction

Hole filling

Extraction of connected components

Convex hall

Thinning

Thickening

Skeleton

9

Page 10: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Outline (cont.)

Gray-scale morphology

Dilation and erosion

Opening and closing

Rank filter, median filter, and majority filter

10

Page 11: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Preview

Mathematical morphology

a tool for extracting image components that are useful in the representation and

description of region shape, such as boundaries, skeletons, and convex hull

Can be used to extract attributes and “meaning” from images, unlike pervious

image processing tools which their input and output were images.

Morphological techniques such as morphological filtering, thinning, and

pruning can be used for pre- or post-processing

All the concepts are introduced on binary images. Some extensions to gray-

scale images are discussed later.

11

Page 12: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Preliminaries

The language of mathematical morphology is set theory:

In binary images, the sets in question are members of the 2-D integer space 𝒁𝟐,

where each element of a set is a 2-D vector whose coordinates are the (x, y)

coordinates of a white pixel (by convention) in the image

12

White pixels of the image represent foreground (1 pixels)

Black pixels of the image are background (0 pixels)

binary images

background

foreground

Page 13: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Preliminaries

In addition to basic set operations including union, intersection,

complement, and difference, we will need:

Translation:

Reflection:

13

Page 14: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Preliminaries

Operations in morphological image processing are shift-invariant

Each operation needs a structuring element (SE)

SE is a binary image, which it’s origin must be specified

Some examples are cross, square, and circle SEs

14

cross square circle

Page 15: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Dilation

The dilation of set A by structuring element B, is defined as

15

Figure 9.6 of Gonzalez book

Page 16: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Dilation

Expands the size of foreground objects

Smooths object boundaries

Closes holes and gaps

16

Original image Dilation with 3 * 3 cross SE Dilation with 7 * 7 cross SE

Original image is taken from MIT course slides

Page 17: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Dilation

Using dilation to fix a text image with broken characters

17

Original image Dilation with 3 * 3 cross SE Dilation with 5 * 5 cross SE

Original image is taken from figure 9.7 of Gonzalez book

Page 18: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Dilation

Dilation is commutative

Dilation is associative

Note: can be decomposed to structuring elements and

This decomposition can cause speed-up

18

Page 19: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Erosion

The erosion of set A by structuring element B, is defined as

19

Figure 9.4 of Gonzalez book

Page 20: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Erosion

Shrinks the size of foreground objects

Smooths object boundaries

Removes peninsulas, fingers and small objects

20

Original image Erosion with 3 * 3 cross SE Erosion with 7 * 7 cross SE

Original image is taken from MIT course slides

Page 21: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Erosion

Using erosion to clear the thin wires in an image

21

Original image Erosion with a disk of radius 10 Erosion with a disk of radius 20Erosion with a disk of radius 5

Original image is taken from figure 9.5 of Gonzalez book

Page 22: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Relationship between dilation and erosion

Duality: Dilation and erosion are duals of each other with respect to set

complementation and reflection

Proof

22

and

Page 23: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

The opening of set A by structuring element B, is defined as

The geometric interpretation of opening

23Opening

Figure 9.8 of Gonzalez book

Page 24: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

The closing of set A by structuring element B, is defined as

The geometric interpretation of closing is based on opening using

duality property

24Closing

Figure 9.9 of Gonzalez book

Page 25: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Duality: Opening and closing are duals of each other with respect to set

complementation and reflection

Proof: homework

25Relationship between opening and closing

and

Page 26: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

26Open filter & close filterOriginal image

Result of opening

Result of openingfollowed by closing

: 3 * 3 square SE

Figure 9.11 of Gonzalez book

Page 27: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

The hit-or-miss transformation of by ,where is a structuring element

pair is defined as

Suppose that is enclosed by a small window . The local background

of with respect to is defined as the set difference , and the

structuring element B2 is as follows

27Hit-or-miss transformation

example

Page 28: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

28Hit-or-miss transformationOriginal image

Structuring

element B1Structuring

element B2

( to be more visible)

Page 29: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Morphological algorithms

Boundary Extraction

Hole filling

Extraction of connected components

Convex hall

Thinning

Thickening

Skeleton

Pruning

29

Page 30: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

The boundary of set can be obtained using erosion

Also the we can use dilation to obtain boundary

The difference between dilation and erosion results thicker boundary

30Boundary extraction

Page 31: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

31Boundary extraction

Original image

Original image is taken from MIT course slides

Page 32: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

32Hole filling

Hole: background region surrounded by a

connected border of foreground pixels

Assumption: a point inside each hole

region is given, , and is symmetric

In each iteration

Termination is at iteration step if

The set union of and contains all filled

holes and their boundaries

Figure is taken from Gonzalez book

Page 33: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

33Extraction of connected components

Connected component: refer to definition!

Assumption: a point on one of the connected

components of set is given and .

The objective is to find all the elements of this

connected component.

In each iteration:

Termination is at iteration step if

is the set containing all the elements of the

connected component.

Figure is taken from Gonzalez book

Page 34: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

34Convex hall

The convex hall of an arbitrary set is the smallest convex set containing .. .

Assumption: represent four structuring elements.

In each iteration: : hit-or-miss transformation

Termination is at iteration step if and we define

Then convex hall of is

Limiting growth of convex hall algorithm along the vertical and horizontal

directions

Page 35: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

35Convex hall

Limiting growth of convex hall algorithm

Figure is taken from Gonzalez book

Page 36: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

The thinning of a set by a structuring element is defined in terms of hit-or-

miss transformation

To thin symmetrically a sequence of structuring elements is used

Where is a rotated version of

Definition of thinning by a set of structuring elements

36Thinning

Page 37: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

37Thinning

Figure is taken from Gonzalez book

Page 38: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Thickening is the morphological dual of thinning and is defined as

Definition of thickening by a set of structuring elements

Usual procedure in practice

Thin the background of a set in question and then complement the result.

Afterwards remove the resulting disconnected points.

The thinned background forms a boundary for the thickening process which is one

of the principal reasons for using this procedure.

38Thickening

Page 39: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

39Thickening

Result of Thinning of Remove disconnected points

Final result of Thickening of

Figure is taken from Gonzalez book

Page 40: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

First we define

The skeleton of set A is

can be reconstructed using

The resulting set may be disconnected

Other algorithms are needed if the skeleton must be maximally thin, connected

and minimally eroded

40Skeleton

Page 41: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

41Skeleton

Original set

Morphological skeleton

Reconstructed set

Figure is taken from Gonzalez book

Page 42: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

The basic operations introduced for binary images are extendable to gray-

scale images

In this case f(x, y) is a gray-scale image and b(x, y) is a structuring element

Structuring elements in gray-scale morphology belong to one of two

categories: non-flat and flat

Gray-scale SEs are used infrequently in practice

42Gray-scale morphology

Page 43: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

The dilation with flat structuring element is defined as

The erosion with flat structuring element is defined as

The dilation with non-flat structuring element is defined as

The erosion with non-flat structuring element is defined as

43Dilation and erosion

Page 44: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

44Dilation and erosion

Example:

Flat SE

Original image Dilation with 5 * 5 square SE Erosion with 5 * 5square SE

Width of lines is not preserved

Page 45: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

As in the binary case, dilation and erosion are duals with respect to function

complementation and reflection

Where

Simplifying the notation

Similarly

45Dilation and erosion

and

Page 46: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

The expressions for Opening and closing gray-scale images have the

same form as their binary counterparts.

Opening

Closing

Duality of opening and closing

46Opening and closing

and

Page 47: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

47Opening and closing

Example 1:

2-D image

Original image Opening with 5 * 5 square SE Closing with 5 * 5 square SE

Width of lines is preserved

Page 48: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

48Opening and closing

Example 2:

1-D signalOriginal 1-D signal

Flat SE, pushed up

underneath the signal

Opening

Flat SE, pushed down

along the top of the signal

Closing

Figure 9.36 of Gonzalez book

Page 49: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Generalization of flat dilation/erosion: instead of using min or max value

in window, use the p-th ranked value

Increases robustness against noise

Best-known example: median filter for noise reduction

Concept useful for both gray-level and binary images

All rank filters are commutative with thresholding

49Rank filter

example

Concepts are taken from MIT course slides

Page 50: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Gray-level images

Median filter: instead of using min or max

value in window, use median value

Binary images

Majority filter: instead of using min or max

value in window, use majority value

50Median filter and majority filter

example

example

Concepts are taken from MIT course slides

Page 51: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

Gonzalez book:

Rafael C. Gonzalez, and Richard E. Woods. Digital image processing, Prentice Hall,

Inc., 2007

MIT course slides:

web.stanford.edu/class/ee368/Handouts/Lectures/2015_Autumn/7-

Morphological_16x9.pdf

51References

Page 52: Digital Image Processing - Sharif University of Technologyce.sharif.edu/courses/94-95/1/ce933-1/resources/root...image processing tools which their input and output were images. Morphological

End of Lecture 10

Thank You!