chapter 9: morphological image processingdylucknow.weebly.com/.../6731187/morphological...i.pdf ·...

46
Morphological Image Processing Presented By: Diwakar Yagyasen Sr. Lecturer CS&E, BBDNITM, Lucknow Digital Image Processing

Upload: others

Post on 17-Aug-2020

12 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Morphological Image Processing

Presented By:Diwakar Yagyasen

Sr. LecturerCS&E, BBDNITM, Lucknow

Digital Image Processing

Page 2: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Preview

Morphology

About the form and structure of animals and plants

Mathematical morphology

Using set theory

Extract image component

Representation and description of region shape

2Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 3: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Preview (cont.)

Sets in mathematical morphology represent objects in an image

Example

Binary image: the elements of a set is the coordinate (x,y) of the pixels, in Z2

Gray-level image: the element of a set is the triple, (x, y, gray-value), in Z3

3Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 4: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Outline

Preliminaries – set theory

Dilation and erosion

Opening and closing

Hit-or-miss transformation

Some basic morphological algorithms

Extensions to gray-scale images

Binaryimages

4Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 5: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Preliminaries – set theory

A be a set in Z2.

a = (a1, a2) is an element of A.

a is not an element of A

Null (empty) set:

Aa

Aa

5Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 6: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Set theory (cont.)

Explicit expression of a set

Example:

naaaA ,...,, 21

elementsset for condition elementA

DddwwC for ,

1

2

6Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 7: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Set operations

A is a subset of B: every element of A is an element of another set B

Union

Intersection

Mutually exclusive

BA

BAC

BAC

BA

7Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 8: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Graphical examples

8Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 9: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Graphical examples (cont.)

AwwAc BwAwwBA ,

9Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 10: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Logic operations on binary images

Functionally complete operations

AND, OR, NOT

10Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 11: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

BA

BA

AB 11

Diwakar Yagyasen, Deptt of CSE, BBDNITM

Page 12: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Special set operationsfor morphology

translation

AazaccA z for ,)(

reflection

BbbwwB for ,ˆ

12Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 13: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Outline

Preliminaries

Dilation and erosion

Opening and closing

Hit-or-miss transformation

Some basic morphological algorithms

Extensions to gray-scale images

13Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 14: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Dilation

)ˆ( ABzBA z B:structuringelement

14Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 15: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Dilation: another formulation

AABzBA z )ˆ(

15Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 16: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Application of dilation: bridging gaps in images

Structuringelement

max. gap=2 pixels

Effects: increase size, fill gap

16Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 17: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Erosion

ABzBA z )(

z: displacement

B:structuringelement

17Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 18: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Erosion (cont.)

18Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 19: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Application of erosion: eliminate irrelevant detail

original image

Squares of size1,3,5,7,9,15 pels

erosion

Erode with13x13 square

dilation

19Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 20: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Dilation and erosion are duals

c

z

c ABzBA )( ) (

cc

z ABz )(

)( c

z ABz

)ˆ( ABzBA z

BAc ˆ

20Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 21: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Application: Boundary extraction

Extract boundary of a set A:

First erode A (make A smaller)

A – erode(A)

) ( BAA=

21Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 22: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Application: boundary extraction

Using 5x5 structuring elementoriginal image

22Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 23: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Outline

Preliminaries

Dilation and erosion

Opening and closing

Hit-or-miss transformation

Some basic morphological algorithms

Extensions to gray-scale images

23Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 24: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Opening

Dilation: expands image w.r.t structuring elements

Erosion: shrink image

erosion+dilation = original image ?

Opening= erosion + dilation

BBABA ) (

24Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 25: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Opening (cont.)

25Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 26: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Opening (cont.)

Smooth the contour of an image, breaks narrow isthmuses, eliminates thin protrusions

Find contour Fill in contour

26Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 27: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Closing

Dilation+erosion = erosion + dilation ?

Closing = dilation + erosion

BBABA )(

27Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 28: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Closing (cont.)

Find contour Fill in contour

Smooth the object contour, fuse narrow breaks and longthin gulfs, eliminate small holes, and fill in gaps

28Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 29: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Properties of opening and closing

Opening

Closing

ABA of (subimage)subset a is (i)

BDBCC ofsubset a is then D,ofsubset a is If (ii)

BABBA )( (iii)

BAA of (subimage)subset a is (i)

BDBCC ofsubset a is then D,ofsubset a is If (ii)

BABBA )( (iii)

29Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 30: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Noisyimage

opening

Removeouternoise

Removeinnernoise

closing

30Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 31: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Outline

Preliminaries

Dilation and erosion

Opening and closing

Hit-or-miss transformation

Some basic morphological algorithms

Extensions to gray-scale images

31Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 32: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Hit-or-miss transformation

Find the location of certain shape

erosion

Find the set of pixels thatcontain shape X

X

32Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 33: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Hit-or-miss transformation

Erosionwith (W-X)

Detect object via background

33Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 34: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Hit-or-miss transformation

Eliminate un-necessary parts

AND

34Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 35: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Outline

Preliminaries

Dilation and erosion

Opening and closing

Hit-or-miss transformation

Some basic morphological algorithms

Extensions to gray-scale images

35Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 36: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Basic morphological algorithms

Extract image components that are useful in the representation and description of shape

Boundary extraction

Region filling

Extract of connected components

Convex hull

Thinning

Thickening

Skeleton

Pruning

36Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 37: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Region filling

How?

Idea: place a point inside the region, then dilate that point iteratively

,...3,2,1,)( 1 kABXX c

kk

pX 0

Until 1 kk XX

Bound the growth

37Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 38: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Region filling (cont.)

stop38

Diwakar Yagyasen, Deptt of CSE, BBDNITM

Page 39: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Application: region filling

Original image

The first filledregion

Fill all regions

39Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 40: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Extraction of connected components

Idea: start from a point in the connected component, and dilate it iteratively

,...3,2,1 ,)( 1 kABXX kk

pX 0

Until 1 kk XX

40Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 41: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Extraction of connected components (cont.)

41Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 42: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

original

thresholding

erosion

42Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 43: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Skeletons

Set A Maximum disk

1. The largest disk Centered at a pixel2. Touch the boundaryof A at two or more places

Recall: Balls of erosion!

How to define a Skeletons?

43Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 44: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Skeleton

Idea: erosion

Erosion k 次直到空集合

44Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 45: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

45Diwakar Yagyasen, Deptt of CSE,

BBDNITM

Page 46: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010

Problem

The scanned image is not adjusted well

How to detection the direction of lines?

How to rotate?

46Diwakar Yagyasen, Deptt of CSE,

BBDNITM