You are on page 1of 13

2004-11-23

1965 : Georges Matheron & Jean Serra

morphologie mathmatique
1965 :
1973 : (, )
1978 :

Centre de Morphologie Mathmatique

1.
(set operation)
N x Mp[0, N
x M-1]column xrow yp = x+Nyp


x = p mod N
y = p/N

AB
aindexA a AaAa A
A B A B
aA
a A a B
AB(Union)
C = AB
AB
C = {p|p A or p B (or both)}
AN M G

p = WHERE(A)
x = p mod N
y = p/N

AB(intersection)
D = AB = {p|p A and p B}
AB
AB =

A(complement)GA:
c

A = {w|w G and w A}
AB(difference)
c

A B = {w|w A and w B} = AB

A(reflection)
A()

//Doing row reflection


xr=x
yr=2*yc-y
//Doing column reflction
xr=2*xc-x
yr=y
//Doing row and column reflction
xr=2*xc-x
yr=2*yc-y
(translation)
x A , A + x,:
A+x = { a+x|aA}
Minkowski
Minkowski

A B = U ( A + b)
bB

Minkowski
A B = I ( A + b)
bB

2.
(discrete space)Z2
A :
A = { a|property(a)==TRUE }
AAc (A) :
Ac = { a| a A }

(dilation)

(erosion)

(dilation)(erosion) A
(local window) structuring element(SE) B)

Minkowski (dilation)(erosion)
(dilation)

D( A, B ) = A B = U ( A + b)
bB

(erosion):

E ( A, B ) = A( B ) = I ( A b)
bB

B = {-b| bB}

(dilation)(erosion)
SE 4-connected 8-connected
, N4 N8

(dilation)(erosion):
Commutative
Non-Commutative
Associative
Translation Invariance
Duality

(decomposition theorems) Vincent


Dilation
Erosion
Erosion
Multiple Dilations

(Opening)(Closing)
dilation erosion

(Opening)
O(AB)= A o B = (A B) B = D(E(AB)B)

(Closing)
C(AB) = A B = ( A B) B =E(D(A, -B),-B)
:
1. A o B is a subset (subimage) of A.
2. If C is subset of D, then C o B is a subset (subimage) of D o B .
3. ( A o B) o B = ( A o B) .
:
1. A is a subset (subimage) of A B .
2. If C is subset of D, then C B is a subset (subimage) of D B .
3. ( A B) B = ( A B) .

(residual)
Residual A
AB =A \ ( A o B )

3.
#include "array.h"
/*-------------------------------------------------------------*/
//

Binary morphological image processing

//

MIAT Lab

//

CHEN Ching-Han2004.11.18

/*-------------------------------------------------------------*/
#define OBJ 0

// object

#define BG 255 // background


#define NumPtSet 5 // number of elements in structuring element
//

// + + + structuring element using N4


//

int seX[NumPtSet]={0,-1,0,1,0},seY[NumPtSet]={-1,0,0,0,1};

void clearImage(uc2D &ima)


{
for(int i=0;i<nr;i++)for(int j=0;j<nc;j++)ima.m[i][j]=BG;

//-------------------------------------------------------------//
//

Binary Mathematical Morphology

//
//-----------------------------------------------------------------//
void binaryDilation(uc2D &im1, uc2D &im2)
{
for(int i=0;i<nr;i++)for(int j=0;j<nc;j++)im2.m[i][j]=im1.m[i][j];
for(int i=1;i<nr-1;i++)for(int j=1;j<nc-1;j++)
{
if(im1.m[i][j]==BG)
for(int k=0;k<NumPtSet;k++)if(im1.m[i+seY[k]][j+seX[k]]==OBJ)
{
im2.m[i][j]=OBJ;
break;
}
}
}
void binaryErosion(uc2D &im1, uc2D &im2)
{
for(int i=0;i<nr;i++)for(int j=0;j<nc;j++)im2.m[i][j]=im1.m[i][j];
for(int i=1;i<nr-1;i++)for(int j=1;j<nc-1;j++)
{
if(im1.m[i][j]==OBJ)
for(int k=0;k<NumPtSet;k++)if(im1.m[i+seY[k]][j+seX[k]]==BG)
{
im2.m[i][j]=BG;
break;
}
}
}
void edgeDetection(uc2D &im1, uc2D &im2)
{
clearImage(im2);
for(int i=1;i<nr-1;i++)for(int j=1;j<nc-1;j++)
{
if(im1.m[i][j]==BG)

for(int k=0;k<NumPtSet;k++)if(im1.m[i+seY[k]][j+seX[k]]==OBJ)
{
im2.m[i][j]=OBJ;
break;
}
}
}
void binaryClosing(uc2D &im1, uc2D &im2)
{
binaryDilation(im1,im2);
binaryErosion(im2,im1);
for(int i=0;i<nr;i++)for(int j=0;j<nc;j++)im2.m[i][j]=im1.m[i][j];
}

void binaryOpenning(uc2D &im1, uc2D &im2)


{
binaryErosion(im1,im2);
binaryDilation(im2,im1);
for(int i=0;i<nr;i++)for(int j=0;j<nc;j++)im2.m[i][j]=im1.m[i][j];
}

1
boundary Image = A-(A B)

(a)(miat400x200.raw)

(b) residual

4. Hit-or-Miss Transform
Hit-or-Miss transform(H-M)
(B1,B2)

B1B2 disjoint(B1 B2 = )
H-M(template matching)B1B2

3x3 1 B10 B2dont


care

H-MB1B2
B1B2

(corner)

H-M
H-M OR

(ending point)
0

1
1
1

1
1
1

2finger120x120.rawHit-or-Miss

5.
(skeleton):
i) (one-pixel),
ii) (middle),
iii) (topology)

(skeleton subset )

K Sk(A) B disc
convex, boundedsymmetricSk(A)

(thinning) hit-and-miss :

B1 B2,
:

(i) an isolated pixel is found (e.g.

),

(ii) removing a pixel would change the connectivity (

(iii) removing a pixel would shorten a line (

),

).

(i)
(counting)
(ii) (i + ii)
(closed
ring)(i + ii + iii)(complete skeleton)

A
S
S ;
While A
E (A B) ;
S S (A \ ( A B ) );
A E;
End While

Bi = {Si, Ti}Si hit Ti miss

8 Bi, i=1,,8 pass pass

3 miat400x200.raw

You might also like