[mmseunion] [Up] [mmcero] Dilations And Erosions

mmcdil
Dilate an image conditionally.

Synopsis

y = mmcdil( f, g, b = None, n = 1 )

Implemented in Python.

Input

f Image Gray-scale (uint8 or uint16) or binary image.
g Image Gray-scale (uint8 or uint16) or binary image.

Conditioning image.

b Structuring Element

Default: None (3x3 elementary cross)

n Double Non-negative integer.

(number of iterations).

Default: 1

Output

y Image

Description

mmcdil 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

Numerical examples:
>>> f = mmbinary(uint8([[1, 0, 0, 0, 0, 0, 0],\
    [0, 0, 0, 0, 0, 0, 0],\
    [0, 0, 0, 0, 1, 0, 0,]]))

              
>>> g = mmbinary(uint8([[1, 1, 1, 0, 0, 1, 1],\
    [1, 0, 1, 1, 1, 0, 0],\
    [0, 0, 0, 0, 1, 0, 0]]));

              
>>> y1=mmcdil(f,g,mmsecross())

              
>>> y2=mmcdil(f,g,mmsecross(),3)
        

            
>>> f = uint8([\
    [   0,    0,   0,   80,   0,   0],\
    [   0,    0,   0,    0,   0,   0],\
    [  10,   10,   0,  255,   0,   0]])

              
>>> g = uint8([\
    [   0,    1,   2,   50,   4,   5],\
    [   2,    3,   4,    0,   0,   0],\
    [  12,  255,  14,   15,  16,  17]])

              
>>> y1=mmcdil(f,g,mmsecross())

              
>>> y2=mmcdil(f,g,mmsecross(),3)
        

            
Binary image:
>>> g=mmreadgray('pcb1bin.tif')

              
>>> f=mmframe(g,5,5)

              
>>> y5=mmcdil(f,g,mmsecross(),5)

              
>>> y25=mmcdil(f,g,mmsecross(),25)

              
>>> mmshow(g)

              
>>> mmshow(g,f)

              
>>> mmshow(g,y5)

              
>>> mmshow(g,y25)
        

            
g g,f
g,y5 g,y25
Gray-scale image:
>>> g=mmneg(mmreadgray('n2538.tif'))

              
>>> f=mmintersec(g,0)
Warning: Converting input image from int32 to uint8.
>>> f=mmdraw(f,'LINE:40,30,60,30:END')

              
>>> y1=mmcdil(f,g,mmsebox())

              
>>> y30=mmcdil(f,g,mmsebox(),30)

              
>>> mmshow(g)

              
>>> mmshow(f)

              
>>> mmshow(y1)

              
>>> mmshow(y30)
        

            
g f y1 y30

Equation

Source Code

def mmcdil(f, g, b=None, n=1):
    if b is None: b = mmsecross()
    y = mmintersec(f,g)
    for i in range(n):
        aux = y
        y = mmintersec(mmdil(y,b),g)
        if mmisequal(y,aux): break
    return y
    

See also

mmfreedom Control automatic data type conversion.
mmdil Dilate an image by a structuring element.
mmsebox Create a box structuring element.
mmsecross Diamond structuring element and elementary 3x3 cross.
mmimg2se Create a structuring element from a pair of images.
mminfrec Inf-reconstruction.
[mmseunion] [Up] [mmcero] Python