Function iacontour

namespace:ia636
page:iacontour

Synopse

Contours of binary images.

  • g = iacontour(f)
    • g: Image.
    • f: Image. input image
01. from numpy import *
02. 
03. def iacontour(f):
04. 
05.     f_ = f > 0
06.     new_shape = array(f_.shape)+2
07.     n = zeros(new_shape); n[0:-2,1:-1] = f_
08.     s = zeros(new_shape); s[2:: ,1:-1] = f_
09.     w = zeros(new_shape); w[1:-1,0:-2] = f_
10.     e = zeros(new_shape); e[1:-1,2:: ] = f_
11.     fi = logical_and(logical_and(logical_and(n,s),w),e)
12.     fi = fi[1:-1,1:-1]
13.     g = f_ - fi
14.     g = g > 0
15.     return g

Description

Contours of binary images.

Examples

Example 1

1. from ia636 import iacontour
2. 
3. f = iaread('blobs.pbm')
4. g = iacontour(f)
5. iashow(f)
6. iashow(g)