[mmsereflect] [Up] [mmseunion] Structuring Elements

mmsedil
Dilate one structuring element by another

Synopsis

Bo = mmsedil( B1, B2 )

Implemented in Python.

Description

mmsedil dilates an structuring element by another. The main difference between this dilation and mmdil is that the dilation between structuring elements are not bounded, returning another structuring element usually larger than anyone of them. This gives the composition of the two structuring elements by Minkowski addition.

Examples

>>> b1 = mmseline(5)

              
>>> mmseshow(b1)
array([0, 0, 0, 0, 1, 1, 1, 1, 1],'1')
>>> b2 = mmsedisk(2)

              
>>> mmseshow(b2)
array([[0, 1, 1, 1, 0],
       [1, 1, 1, 1, 1],
       [1, 1, 1, 1, 1],
       [1, 1, 1, 1, 1],
       [0, 1, 1, 1, 0]],'1')
>>> b3 = mmsedil(b1,b2)

              
>>> mmseshow(b3)
        
array([[0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0],
       [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1],
       [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1],
       [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1],
       [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0]],'1')

Equation

Flat structuring element:

Source Code

def mmsedil(B1, B2):
    from Numeric import NewAxis, array
    assert ((mmdatatype(B1) == 'binary') or (mmdatatype(B1) == 'int32')) and (
            (mmdatatype(B2) == 'binary') or (mmdatatype(B2) == 'int32')),'SE must be binary or int32'
    if len(B1.shape) == 1: B1 = B1[NewAxis,:]
    if len(B2.shape) == 1: B2 = B2[NewAxis,:]
    if (mmdatatype(B1) == 'int32') or (mmdatatype(B2) == 'int32'):
       Bo = int32([mmlimits(int32([0]))[0]])
       if mmdatatype(B1) == 'binary':
          B1 = mmgray(B1,'int32',0)
       if mmdatatype(B2) == 'binary':
          B2 = mmgray(B2,'int32',0)
    else:
       Bo = mmbinary([0])
    x,v = mmmat2set(B2)
    if len(x):
        for i in range(x.shape[0]):
            s = mmadd4dil(B1,v[i])
            st= mmsetrans(s,x[i])
            Bo = mmseunion(Bo,st)
    return Bo
    

See also

mmdil Dilate an image by a structuring element.
mmseshow Display a structuring element as an image.
mmero Erode an image by a structuring element.
mmsesum N-1 iterative Minkowski additions
mmseunion Union of structuring elements
[mmsereflect] [Up] [mmseunion] Python