[mmserot] [Up] [mmsesum] Structuring Elements

mmseshow
Display a structuring element as an image.

Synopsis

y = mmseshow( B, option = "NORMAL" )

Implemented in Python.

Input

B Structuring Element
option String

'NORMAL', ' EXPAND' or ' NON-FLAT'

Default: "NORMAL"

Output

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

Description

mmseshow used with the option EXPAND generates an image y that is a suitable graphical representation of the structuring element B. This function is useful to convert a structuring element to an image. The origin of the structuring element is at the center of the image. If B is flat, y is binary, otherwise, y is signed int32 image. When using the option NON-FLAT, the output y is always a signed int32 image.

Examples

Flat structuring element
>>> b=mmsecross(3);

              
>>> print mmseshow(b)
[[0 0 0 1 0 0 0]
 [0 0 1 1 1 0 0]
 [0 1 1 1 1 1 0]
 [1 1 1 1 1 1 1]
 [0 1 1 1 1 1 0]
 [0 0 1 1 1 0 0]
 [0 0 0 1 0 0 0]]
>>> a = mmseshow(b,'EXPAND')

              
>>> mmshow(a)

              
>>> print mmseshow(b,'NON-FLAT')
[[-2147483647 -2147483647 -2147483647           0 -2147483647 -2147483647
       -2147483647]
 [-2147483647 -2147483647           0           0           0 -2147483647
       -2147483647]
 [-2147483647           0           0           0           0           0
       -2147483647]
 [          0           0           0           0           0           0
                 0]
 [-2147483647           0           0           0           0           0
       -2147483647]
 [-2147483647 -2147483647           0           0           0 -2147483647
       -2147483647]
 [-2147483647 -2147483647 -2147483647           0 -2147483647 -2147483647
       -2147483647]]
a
Non flat structuring element
>>> b=mmsedisk(2,'2D','EUCLIDEAN','NON-FLAT')

              
>>> print mmseshow(b)
[[-2147483647           1           1           1 -2147483647]
 [          1           2           2           2           1]
 [          1           2           2           2           1]
 [          1           2           2           2           1]
 [-2147483647           1           1           1 -2147483647]]

Source Code

def mmseshow(B, option="NORMAL"):
    from string import upper
    option = upper(option)            
    if option=='NON-FLAT': 
        y=int32([0])
        if mmisbinary(B):
            B = mmintersec(mmgray(B,'int32'),0)
    elif option=='NORMAL':
        if mmisbinary(B):    y=mmbinary([1])
        else:
           y=int32([0])
    elif option=='EXPAND':
        assert mmisbinary(B), 'This option is only available with flat SE'
        y = mmsedil(mmbinary([1]),B)
        b1= mmbinary(y>=0)
        b0= mmero(y,B)
        y = mmbshow(b1,y,b0)
        return y
    else:
        print 'mmseshow: not a valid flag: NORMAL, EXPAND or NON-FLAT'
    y = mmsedil(y,B)
    return y
    

See also

mmfreedom Control automatic data type conversion.
mmimg2se Create a structuring element from a pair of images.
mmsebox Create a box structuring element.
mmsecross Diamond structuring element and elementary 3x3 cross.
mmsedisk Create a disk or a semi-sphere structuring element.
mmseline Create a line structuring element.
[mmserot] [Up] [mmsesum] Python