[ialogfilter] [Up] [iaconv] Image Filtering

iacontour
Contours of binary images.

Synopsis

g = iacontour( f )

Implemented in Python.

Input

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

input image

Output

g Image. Accepts any image data type.

Description

Contours of binary images.

Examples

>>> f = iaread('blobs.pbm')

              
>>> g = iacontour(f)

              
>>> iashow(f)
(128, 128) Min= 0 Max= 1 Mean=0.482 Std=0.50
>>> iashow(g)
(128, 128) Min= 0 Max= 1 Mean=0.074 Std=0.26
f g

Source Code

def iacontour(f):
    from Numeric import array, zeros, logical_and
    f_ = f > 0
    new_shape = array(f_.shape)+2
    n = zeros(new_shape); n[0:-2,1:-1] = f_
    s = zeros(new_shape); s[2:: ,1:-1] = f_
    w = zeros(new_shape); w[1:-1,0:-2] = f_
    e = zeros(new_shape); e[1:-1,2:: ] = f_
    fi = logical_and(logical_and(logical_and(n,s),w),e)
    fi = fi[1:-1,1:-1]
    g = f_ - fi
    g = g > 0
    return g
    
[ialogfilter] [Up] [iaconv] http://www.python.org