Function iathin

Synopse

Image transformation by thinning.

  • y = iathin(f, Iab=ia_homothin(), n=-1, theta=45, DIRECTION="CLOCKWISE")
    • y: Image
    • f: Image
    • Iab: Interval
    • n: Double Number of iterations.
    • theta: Double Degrees of rotation: 45, 90, or 180.
    • DIRECTION: String Direction of rotation: 'CLOCKWISE' or ' ANTI-CLOCKWISE'
01. from numpy import *
02. from string import upper
03. 
04. def iathin(f, Iab=None, n=-1, theta=45, DIRECTION="CLOCKWISE"):
05.     import ia870 as MT
06. 
07.     if Iab is None: Iab = MT.iahomothin()
08. 
09.     DIRECTION = upper(DIRECTION)
10.     assert MT.iaisbinary(f),'f must be binary image'
11.     if n == -1: n = product(f.shape)
12.     y = f
13.     zero = MT.iaintersec(f,0)
14.     for i in range(n):
15.         aux = zero
16.         for t in range(0,360,theta):
17.             sup = MT.iasupgen( y, MT.iainterot(Iab, t, DIRECTION))
18.             aux = MT.iaunion( aux, sup)
19.             #y -= sup
20.             y = MT.iasubm( y, sup)
21.         #if iaisequal(aux,zero): break
22.         if not aux.any(): break
23.     return y

Description

iathin 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 None (default conditions), iathin gives the skeleton by thinning.

Examples

Example 1

1. from ia870 import iathin, iaendpoints, iagshow
2. 
3. f=adread('scissors.tif')
4. f1=iathin(f)
5. adshow(iagshow(f,f1)) # skeleton
6. f2=iathin(f1,iaendpoints(),15) # prunning 15 pixels
7. adshow(iagshow(f,f2)) # prunned skeleton

Equation