[mmcenter] [Up] [mmclose] Morphological Filters

mmasf
Alternating Sequential Filtering

Synopsis

y = mmasf( f, SEQ = "OC", b = None, n = 1 )

Implemented in Python.

Input

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

'OC', 'CO', 'OCO', 'COC'.

Default: "OC"

b Structuring Element

Default: None (Diamond structuring element with radius 1)

n Double Non-negative integer.

(number of iterations).

Default: 1

Output

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

Description

mmasf creates the image y by filtering the image f by n iterations of the close and open alternating sequential filter characterized by the structuring element b. The sequence of opening and closing is controlled by the parameter SEQ. 'OC' performs opening after closing, 'CO' performs closing after opening, 'OCO' performs opening after closing after opening, and 'COC' performs closing after opening after closing.

Examples

Binary image:
>>> f=mmreadgray('gear.tif')

              
>>> g=mmasf(f,'oc',mmsecross(),2)

              
>>> mmshow(f)

              
>>> mmshow(g)

            
f g
Gray-scale image:
>>> f=mmreadgray('fabric.tif')

              
>>> g=mmasf(f,'oc',mmsecross(),3)

              
>>> mmshow(f)

              
>>> mmshow(g)

            
f g

Equation

Case oc:
Case co:
Case oco:
Case coc:

Source Code

def mmasf(f, SEQ="OC", b=None, n=1):
    from string import upper
    if b is None: b = mmsecross()
    SEQ=upper(SEQ)
    y = f
    if SEQ == 'OC':
        for i in range(1,n+1):
            nb = mmsesum(b,i)
            y = mmopen(mmclose(y,nb),nb)
    elif SEQ == 'CO':
        for i in range(1,n+1):
            nb = mmsesum(b,i)
            y = mmclose(mmopen(y,nb),nb)
    elif SEQ == 'OCO':
        for i in range(1,n+1):
            nb = mmsesum(b,i)
            y = mmopen(mmclose(mmopen(y,nb),nb),nb)
    elif SEQ == 'COC':
        for i in range(1,n+1):
            nb = mmsesum(b,i)
            y = mmclose(mmopen(mmclose(y,nb),nb),nb)
    return y
    

See also

mmfreedom Control automatic data type conversion.
mmsebox Create a box structuring element.
mmsecross Cross structuring element.
mmopen Morphological opening.
mmclose Morphological closing.
mmasfrec Reconstructive Alternating Sequential Filtering
[mmcenter] [Up] [mmclose] Python