Function iaskelmrec

namespace:morph
page:iaskelmrec

Synopse

Morphological skeleton reconstruction (Inverse Medial Axis Transform).

  • y = iaskelmrec(f, B=ia_secross(NULL))
    • y: Image
    • f: Image
    • B: Structuring Element
01. from numpy import *
02. 
03. def iaskelmrec(f, B=None):
04.     from iabinary import iabinary
05.     from iaintersec import iaintersec
06.     from iadil import iadil
07.     from iaunion import iaunion
08.     from iasecross import iasecross
09.     if B is None:
10.         B = iasecross(None)
11. 
12.     y = iabinary( iaintersec(f, 0))
13.     for r in range(max(ravel(f)),1,-1):
14.         y = iadil( iaunion(y,iabinary(f,r)), B)
15.     y = iaunion(y, iabinary(f,1))
16.     return y

Description

iaskelmrec reconstructs the valued morphological skeleton to recover the original image.

Examples

Example 1

01. from ia870 import iaskelmrec
02. from ia870 import ianeg
03. from ia870 import iaframe
04. from ia870 import iabinary
05. from ia870 import iaskelm
06. from ia870 import iasecross
07. 
08. 
09. a=ianeg( iaframe( iabinary(ones((7,9)))))
10. print a
11. b=iaskelm(a,iasecross(),'value')
12. print b
13. c=iaskelmrec(b,iasecross())
14. print c
[[False False False False False False False False False]
 [False  True  True  True  True  True  True  True False]
 [False  True  True  True  True  True  True  True False]
 [False  True  True  True  True  True  True  True False]
 [False  True  True  True  True  True  True  True False]
 [False  True  True  True  True  True  True  True False]
 [False False False False False False False False False]]
[[False False False False False False False False False False False]
 [False False False False False False False False False False False]
 [False False  True  True  True  True  True  True  True False False]
 [False False  True  True  True  True  True  True  True False False]
 [False False  True  True  True  True  True  True  True False False]
 [False False  True  True  True  True  True  True  True False False]
 [False False  True  True  True  True  True  True  True False False]
 [False False False False False False False False False False False]
 [False False False False False False False False False False False]]
[[0 0 0 0 0 0 0 0 0]
 [0 1 0 0 0 0 0 1 0]
 [0 0 2 0 0 0 2 0 0]
 [0 0 0 3 3 3 0 0 0]
 [0 0 2 0 0 0 2 0 0]
 [0 1 0 0 0 0 0 1 0]
 [0 0 0 0 0 0 0 0 0]]
[[False False False False False False False False False]
 [False  True  True  True  True  True  True  True False]
 [False  True  True  True  True  True  True  True False]
 [False  True  True  True  True  True  True  True False]
 [False  True  True  True  True  True  True  True False]
 [False  True  True  True  True  True  True  True False]
 [False False False False False False False False False]]