[mmthick] [Up] [mmwatershed] Thinning And Thickening

mmthin
Image transformation by thinning.

Synopsis

y = mmthin( f, Iab = None, n = -1, theta = 45, DIRECTION = "CLOCKWISE" )

Implemented in Python.

Input

f Image Binary image.
Iab Interval

Default: None (mmhomothin)

n Double Non-negative integer.

Number of iterations.

Default: -1

theta Double

Degrees of rotation: 45, 90, or 180.

Default: 45

DIRECTION String

'CLOCKWISE' or ' ANTI-CLOCKWISE'

Default: "CLOCKWISE"

Output

y Image Binary image.

Description

mmthin creates the binary image y by performing a thinning of the binary image f. The number of iterations of the thinning is n and each iteration is performed by subtracting the points that are detect in f by hit-miss operators characterized by rotations of theta of the interval Iab. When n is infinite and the interval is mmhomothin (default conditions), mmthin gives the skeleton by thinning.

Examples

>>> f=mmreadgray('scissors.tif')

              
>>> f1=mmthin(f)

              
>>> mmshow(f,f1) # skeleton

              
>>> f2=mmthin(f1,mmendpoints(),15) # prunning 15 pixels

              
>>> mmshow(f,f2) # prunned skeleton

            
f,f1 f,f2

Equation

Source Code

def mmthin(f, Iab=None, n=-1, theta=45, DIRECTION="CLOCKWISE"):
    from Numeric import product
    from string import upper
    if Iab is None: Iab = mmhomothin()
    DIRECTION = upper(DIRECTION)            
    assert mmisbinary(f),'f must be binary image'
    if n == -1: n = product(f.shape)
    y = f
    zero = mmintersec(f,0)
    for i in range(n):
        aux = zero
        for t in range(0,360,theta):
            sup = mmsupgen( y, mminterot(Iab, t, DIRECTION))
            aux = mmunion( aux, sup)
            y = mmsubm( y, sup)
        if mmisequal(aux,zero): break
    return y
    

See also

mmfreedom Control automatic data type conversion.
mmcthin Image transformation by conditional thinning.
mmthick Image transformation by thickening.
mmendpoints Interval to detect end-points.
mmhomothin Interval for homotopic thinning.
mmse2hmt Create a Hit-or-Miss Template (or interval) from a pair of structuring elements.
[mmthick] [Up] [mmwatershed] Python