[mmadd4dil] [Up] Python functions

mmpad4n
mmpad4n

Synopsis

y = mmpad4n( f, Bc, value, scale = 1 )

Implemented in Python.

Input

f Image
Bc Structuring Element

( connectivity).

value int.
scale int.

Default: 1

Output

y

The converted image

Source Code

def mmpad4n(f, Bc, value, scale=1):
    from Numeric import ones, array
    if type(Bc) is not array:
      Bc = mmseshow(Bc)            
    Bh, Bw = Bc.shape
    assert Bh%2 and Bw%2, 'structuring element must be odd sized'
    ch, cw = scale * Bh/2, scale * Bw/2
    g = value * ones( f.shape + scale * (array(Bc.shape) - 1))
    g[ ch: -ch, cw: -cw] = f
    y = g.astype( f.typecode())
    return y
    
[mmadd4dil] [Up] Python