[mmsupgen] [Up] [mmcthin] Thinning And Thickening

mmcthick
Image transformation by conditional thickening.

Synopsis

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

Implemented in Python.

Input

f Image Binary image.
g Image Binary image.
Iab Interval

Default: None (mmhomothick)

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

mmcthick creates the binary image y by performing a thickening of the binary image f conditioned to the binary image g. The number of iterations of the conditional thickening is n and in each iteration the thickening is characterized by rotations of theta of the interval Iab.

Examples

Pseudo convex hull
>>> f=mmreadgray('blob2.tif')

              
>>> mmshow(f)

              
>>> t=mmse2hmt(mmbinary([[0,0,0],[0,0,1],[1,1,1]]),
                          mmbinary([[0,0,0],[0,1,0],[0,0,0]]))

              
>>> print mmintershow(t)
. . . 
. 0 1 
1 1 1
>>> f1=mmthick(f,t,40); # The thickening makes the image border grow

              
>>> mmshow(f1)

            
f f1
>>> f2=mmcthick(f,mmneg(mmframe(f)),t,40) # conditioning to inner pixels

              
>>> fn=mmcthick(f,mmneg(mmframe(f)),t) #pseudo convex hull

              
>>> mmshow(f2)

              
>>> mmshow(fn,f)

            
f2 fn,f

Equation

Source Code

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

See also

mmfreedom Control automatic data type conversion.
mmthick Image transformation by thickening.
mmhomothick Interval for homotopic thickening.
mmse2hmt Create a Hit-or-Miss Template (or interval) from a pair of structuring elements.
[mmsupgen] [Up] [mmcthin] Python