Function iacdil

namespace:morph
page:iacdil

Synopse

Dilate an image conditionally.

  • y = iacdil(f, g, b=iasecross(), n=1)
    • y: Image
    • f: Image
    • g: Image Conditioning image.
    • b: Structuring Element
    • n: Double (number of iterations).
01. from numpy import *
02. from iasecross import iasecross
03. 
04. def iacdil(f, g, b=iasecross(), n=1):
05.     from iaintersec import iaintersec
06.     from iadil import iadil
07.     from iaisequal import iaisequal
08. 
09.     y = iaintersec(f,g)
10.     for i in xrange(n):
11.         aux = y
12.         y = iaintersec( iadil(y,b),g)
13.         if iaisequal(y,aux): break
14.     return y

Description

iacdil creates the image y by dilating the image f by the structuring element b conditionally to the image g. This operator may be applied recursively n times.

Examples

Example 1

01. from ia870 import iacdil, iabshow
02. from ia870 import iasecross
03. 
04. f = array([[1, 0, 0, 0, 0, 0, 0],\
05.            [0, 0, 0, 0, 0, 0, 0],\
06.            [0, 0, 0, 0, 1, 0, 0,]],bool)
07. g = array([[1, 1, 1, 0, 0, 1, 1],
08.            [1, 0, 1, 1, 1, 0, 0],
09.            [0, 0, 0, 0, 1, 0, 0]], bool)
10. y1=iacdil(f,g)
11. y2=iacdil(f,g,iasecross(),3)
12. adshow(iabshow(f),'f')
13. adshow(iabshow(g),'g')
14. adshow(iabshow(y1),'iacdil(f,g)')
15. adshow(iabshow(y2),'iacdil(f,g,cross,3)')

f

g

iacdil(f,g)

iacdil(f,g,cross,3)

Example 2

01. f = array([\
02.     [   0,    0,   0,   80,   0,   0],\
03.     [   0,    0,   0,    0,   0,   0],\
04.     [  10,   10,   0,  255,   0,   0]],uint8)
05. g = array([\
06.     [   0,    1,   2,   50,   4,   5],\
07.     [   2,    3,   4,    0,   0,   0],\
08.     [  12,  255,  14,   15,  16,  17]],uint8)
09. y1=iacdil(f,g)
10. y2=iacdil(f,g,iasecross(),3)
11. print 'y1=\n',y1
12. print 'y2=\n',y2
y1=
[[ 0  0  2 50  4  0]
 [ 2  3  0  0  0  0]
 [10 10 14 15 15  0]]
y2=
[[ 0  1  2 50  4  4]
 [ 2  3  4  0  0  0]
 [12 14 14 15 15 15]]

Example 3

01. from ia870 import iaframe, iagshow
02. 
03. g=adreadgray('pcb1bin.tif') > 0
04. f=iaframe(g,5,5)
05. y5=iacdil(f,g,iasecross(),5)
06. y25=iacdil(f,g,iasecross(),25)
07. adshow(g)
08. adshow(iagshow(g,f))
09. adshow(iagshow(g,y5))
10. adshow(iagshow(g,y25))

Example 4

01. from ia870 import ianeg
02. from ia870 import iaintersec
03. from ia870 import iasebox
04. 
05. g=ianeg( adreadgray('n2538.tif'))
06. f=iaintersec(g,0)
07. f[40:60,30] = 255
08. y1=iacdil(f,g,iasebox())
09. y30=iacdil(f,g,iasebox(),30)
10. adshow(g)
11. adshow(f)
12. adshow(y1)
13. adshow(y30)

Equation

See Also