Top Banner
3/31/2008 1 Lecture 8 (3.31.08) Morphological Image Processing Shahram Ebadollahi DIP ELEN E4830 A number of figures used in this presentation are courtesy of “Morphological Image Analysis” by P. Soille
48

Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

Aug 29, 2018

Download

Documents

doanthuan
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: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 1

Lecture 8 (3.31.08)

Morphological Image Processing

Shahram Ebadollahi

DIP ELEN E4830

A number of figures used in this presentation are courtesy of “Morphological Image Analysis” by P. Soille

Page 2: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 2

Outline

� What is Mathematical Morphology?� Background Notions � Introduction to Set Operations on Images� Basic operation� Erosion, Dilation, Opening, Closing, Hit-or-Miss

� Algorithms� Morphological operations on gray-level

images

Page 3: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 3

� Started in 1960s by G. Matheron and J. Serra

� Analysis of form and structure of objects

� Tools/Operations for describing/characterizing image regions and image filtering

� Images are treated as sets

Morphological Image Processing

Morphological Image

Transformf g

Ψ

•Point

•neighborhood

][ fg Ψ=

Image-to-image transform

Page 4: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 4

Applications - filtering

Page 5: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 5

Applications - segmentation

Page 6: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 6

Applications - quantification

Page 7: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 7

Background Notions:Image as a Set

{ }max,,1,0: tDf nf �→Ζ⊂

{ })(|),()( 0 xfttxfG n =Ν×Ζ∈=

{ })(0|),()( 0 xfttxfSG n ≤≤Ν×Ζ∈=

Image Graph

Image Sub-Graph

{ }1,0: →Ζ⊂ nfDf

Binary image

Grey-level image

• How could the grey-level image be treated as a set?

definition domain of f –or- image plane

Image as a set: Set of all white pixels

Image as Digital Elevation Map (DEM)

Page 8: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 8

Background Notions:Gray-level Image as a Set

Page 9: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 9

Set Operations on Images -Union & Intersection

Union

Intersection

[ ])(),(max))(( xgxfxgf =∨

[ ])(),(min))(( xgxfxgf =∧

)()()( gSGfSGgfSG �=∨

)()()( gSGfSGgfSG �=∧

( )( ) )()()(

)()()(

2121

2121

fff

fff

Ψ∧Ψ=Ψ∧ΨΨ∨Ψ=Ψ∨Ψ

Page 10: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 10

Set Operations on Images

)()( max xftxf c −=

)()( bxfxfb −=

{ }BbbB ∈−=∨

|

Reflection

Translation

Complementationmax fcf

Set Difference

cYXYX �=\Note: Only on binary images

∈∀= −∨

xxgg )(

Page 11: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 11

•All morphological image operations are the result of interaction between a set representing an imageand a set representing a structuring element

•All interactions are based on combination of intersection, union, complementation and translation

Morphological Image Operations

Page 12: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 12

Graphs

Graph is a pair of vertices and edges (V,E), where:

( )( )m

n

eeeE

vvvV

,,,

,,,

21

21

==

• Planar graph

• Simple graph

{ }EvvVvvNG ∈∈= )',(|')(Neighborhood of vertex v:

Path P in graph G: neighborsvvvvvP iilG ),(,),,,( 110 += �

hGP

Page 13: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 13

Grids & Connectivity

Connectivity:a set is connected if each pair of its points can be joined by a path completely in the set

Gh-Connectivty:2 pixel p and q of image f are G h-connected iff there exists a path with end points p and q

hGP

Page 14: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 14

Structuring Element (SE):A Small Set for Probing Images

Page 15: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 15

Erosion: “ Does the SE fit the set?”

{ }XBxX xB ⊆= |)(ε : Eroding set X with SE B

bBb

B XX −∈

= �)(ε∨

−= BXXB )(ε

Page 16: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 16

Erosion: Implementation

bBb

B ff −∈∧=)(ε

)(min))](([ bxfxfBb

B +=⇒∈

ε

)( fBε

fB

1+f

1−f

Page 17: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 17

Erosion: “ Does the SE fit the set?”Grey-level image

)}(|),{()]([ ),( fSGBtxfSG txB ⊆=ε

Page 18: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 18

Dilation: “ Does the SE hit the set?”

{ }φδ ≠∩= XBxX xB |)( : Dilating set X with SE B

bBb

B XX −∈

= �)(δ∨

⊕= BXXB )(δ

Page 19: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 19

Dilation: Implementation

bBb

B ff −∈∨=)(δ

)(max))](([ bxfxfBb

B +=⇒∈

δ

fB

1+f

1−f

)( fBδ

Page 20: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 20

Dilation: “ Does the SE hit the set?”Grey-level image

})(|),{()]([ ),( φδ ≠= fSGBtxfSG txB �

Page 21: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 21

Erosion and Dilation: Examples

Dilation

Erosion then

Dilation

Page 22: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 22

Erosion and Dilation:Example

Basic morphological operations in Matlab

Page 23: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 23

Properties of Erosion and Dilation

Duality CC BB δε =

cB

B

bBb

bBbc

B

f

ft

ft

ftf

)]([

)(

][

][)(

max

max

max

εε

δ

=

−=∧−=

−∨=

−∈

−∈

• Erosion and Dilation are irreversible operations

• Homotopy is not preserved under either one

Page 24: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 24

Properties of Erosion and Dilation

Increasingness

Distributivity

≤≤

⇒≤)()(

)()(

gf

gfgf

δδεε

)()( ii

ii

ff δδ ∨=∨

)()( ii

ii

ff εε ∧=∧

Page 25: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 25

Properties of Erosion and Dilation

Composition

)()( ))(( 12

12ff BBB

B∨

= δδδδ

)()( ))(( 12

12ff BBB

B∨

= δεεε

)(nBnB δδ =

Break down operations using large SE with multiple operations with small SE.

1B 2B )( 12BBδ

Making a circular disk

Page 26: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 26

Opening –“If SE fits image then keep all SE!”

)]([)( ff BB

B εδγ ∨=

}|{)( XBBX xxx

B ⊆=�γ

Page 27: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 27

Opening –“If SE fits the image then keep all SE!”

)( fBε )( fBγ

Page 28: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 28

Closing –“If SE fits the background then all points in SE belong to the complement of closing!”

)]([)( ff BB

B δεφ ∨=

}|{)( cx

cx

xB BXBX ⊆=�φ

Page 29: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 29

Closing)( fBδ )( fBφ

Page 30: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 30

Properties of Opening and Closing

Duality CC BB φγ =

Increasingness

≤≤

⇒≤)()(

)()(

gf

gfgf

φφγγ

Idempotence γγ =)(n

φφ =)(n

Sieving process: same sieve is not helpful using it more than once

Page 31: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 31

Opening and Closing: Example

Page 32: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 32

Opening and Closing: Example

Page 33: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 33

Top Hat transform

)()( fffWTH γ−=

fffBTH −= )()( φ

)( fBγ)( fWTH

)( fBφ )( fBTH

Page 34: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 34

Top Hat transform

Page 35: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 35

Hit-or-Miss

})(,)(|{)( cxBGxFGB XBXBxXHMT ⊆⊆=

)()()( cBBB XXXHMT

BGFGεε �=

)()( c

BB XHMTXHMT c=• Property:

where, ),( 21 BBB =),( 12 BBBc =

Page 36: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 36

Thinning and Thickening

)()( fHMTffTHIN BB −=

)()( fHMTffTHICK BB +=

Page 37: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 37

Example Applications: Boundary Extraction

)()( fff Bεβ −=

Page 38: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 38

Example Applications: Region Filling

( ) �� ,3,2,11 == − kAXX ckBk δ

• start with X0=p

• stop when Xk=Xk-1

Page 39: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 39

Example Applications: Connected component extraction

( ) �� ,3,2,11 == − kAXX kBk δ

Page 40: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 40

Example Applications: Convex Hull

( ) �� ,3,2,14,3,2,11 === − kiAXHMTX kB

ik i

AX i =0

ik

i XD =

�4

1

)(=

=i

iDAC

Page 41: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 41

Skeletonization

�K

kk ASAS

0

)()(=

=

( ))()()( AAAS kBBkBk εφε −=

{ }nullAkK kB ≠= )(|max ε

�K

kkkB ASA

0

)))(((=

= δ

Page 42: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 42

Skeletonization (Medial Axis Transform)

Notion of “Maximal Disc”B is a “Maximal Disc” in set X if there are no other discs included in X and containing B

Skeleton is the loci of the centers of all “maximal discs”

{ })]([\)()(0

XXXS kBBkBk

εγε≥

= �

Page 43: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 43

Skeletonization

)()(0

XSXS k

K

k== �

))(()()( XXXS kBBkBk εγε −=

)))(((()( XX BBBkB εεεε �=

{ }φε ≠= )(|max XkK kB

))((0

XSX kkB

K

== �

))))((((()( XSX kBBBkB δδδδ �=

Notion of “Maximal Disc”

Skeleton is the loci of the centers of all “maximal discs”

Reconstruction

Page 44: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 44

Matlab examples - dilationoriginalBW = imread('text.png');se = strel('line',11,90);dilatedBW = imdilate(originalBW,se);figure, imshow(originalBW), figure, imshow(dilatedB W)

originalI = imread('cameraman.tif');se = strel('ball',5,5);dilatedI = imdilate(originalI,se);figure, imshow(originalI), figure, imshow(dilatedI)

se1 = strel('line',3,0);se2 = strel('line',3,90);composition = imdilate(1,[se1 se2],'full')

Page 45: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 45

originalBW = imread('text.png');se = strel('line',11,90);erodedBW = imerode(originalBW,se);figure, imshow(originalBW)figure, imshow(erodedBW)

originalI = imread('cameraman.tif');se = strel('ball',5,5);erodedI = imerode(originalI,se);figure, imshow(originalI), figure, imshow(erodedI)

Matlab examples - erosion

Page 46: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 46

originalBW = imread('circles.png');figure, imshow(originalBW);se = strel('disk',10);closeBW = imclose(originalBW,se);figure, imshow(closeBW);

Matlab examples - closing

Page 47: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 47

original = imread('snowflakes.png');se = strel('disk',5);afterOpening = imopen(original,se);figure, imshow(original), figure, imshow(afterOpeni ng)

Matlab examples - opening

Page 48: Morphological Image Processing Shahram Ebadollahixlx/courses/ee4830-sp08/notes/lec8_final.pdf · Morphological Image Processing Shahram Ebadollahi ... HMT X =HMT c X where, B = ...

3/31/2008 48

bw=[0 0 0 0 0 00 0 1 1 0 00 1 1 1 1 00 1 1 1 1 00 0 1 1 0 00 0 1 0 0 0]

interval = [0 -1 -11 1 -10 1 0];

bw2 = bwhitmiss(bw,interval)

Matlab examples - HMT