Beispiel #1
0
def iacdil(f, g, b=iasecross(), n=1):
    from ia870.iaintersec import iaintersec
    from ia870.iadil import iadil
    from ia870.iaisequal import iaisequal

    y = iaintersec(f, g)
    for i in range(n):
        aux = y
        y = iaintersec(iadil(y, b), g)
        if iaisequal(y, aux): break
    return y
Beispiel #2
0
def iatoggle(f, f1, f2, OPTION="GRAY"):
    from ia870.iabinary import iabinary
    from ia870.iasubm import iasubm
    from ia870.iagray import iagray
    from ia870.iaunion import iaunion
    from ia870.iaintersec import iaintersec
    from ia870.ianeg import ianeg

    y = iabinary(iasubm(f, f1), iasubm(f2, f))
    if OPTION.upper() == 'GRAY':
        t = iagray(y)
        y = iaunion(iaintersec(ianeg(t), f1), iaintersec(t, f2))

    return y
Beispiel #3
0
def iathick(f, Iab=None, n=-1, theta=45, DIRECTION="CLOCKWISE"):
    from ia870.iaisbinary import iaisbinary
    from ia870.iaintersec import iaintersec
    from ia870.iasupgen import iasupgen
    from ia870.iainterot import iainterot
    from ia870.iaunion import iaunion
    from ia870.iaisequal import iaisequal
    from ia870.iahomothick import iahomothick
    if Iab is None:
        Iab = iahomothick()

    DIRECTION = DIRECTION.upper()
    assert iaisbinary(f), 'f must be binary image'
    if n == -1: n = product(f.shape)
    y = f
    zero = iaintersec(f, 0)
    for i in range(n):
        aux = zero
        for t in range(0, 360, theta):
            sup = iasupgen(y, iainterot(Iab, t, DIRECTION))
            aux = iaunion(aux, sup)
            y = iaunion(y, sup)
        if iaisequal(aux, zero): break

    return y
Beispiel #4
0
def iaskelm(f, B=iasecross(), option="binary"):
    from ia870.iaisbinary import iaisbinary
    from ia870.ialimits import ialimits
    from ia870.iagray import iagray
    from ia870.iaintersec import iaintersec
    from ia870.iasesum import iasesum
    from ia870.iaero import iaero
    from ia870.iaisequal import iaisequal
    from ia870.iaopenth import iaopenth
    from ia870.iasedil import iasedil
    from ia870.iaunion import iaunion
    from ia870.iabinary import iabinary
    from ia870.iapad import iapad
    from ia870.iaunpad import iaunpad

    assert iaisbinary(f),'Input binary image only'
    option = option.upper()
    f = iapad(f,B)
    print(f)
    k1,k2 = ialimits(f)
    y = iagray( iaintersec(f, k1),'uint16')
    iszero = asarray(y)
    nb = iasesum(B,0)
    for r in range(1,65535):
        ero = iaero( f, nb)
        if iaisequal(ero, iszero): break
        f1 = iaopenth( ero, B)
        nb = iasedil(nb, B)
        y = iaunion(y, iagray(f1,'uint16',r))
    if option == 'BINARY':
        y = iabinary(y)
    y = iaunpad(y,B)
    return y
Beispiel #5
0
def iasupgen(f, INTER):
    from ia870.iaintersec import iaintersec
    from ia870.iaero import iaero
    from ia870.ianeg import ianeg

    A, Bc = INTER
    y = iaintersec(iaero(f, A), iaero(ianeg(f), Bc))

    return y
Beispiel #6
0
def iacmp(f1, oper, f2, oper1=None, f3=None):
    from ia870.iaintersec import iaintersec
    from ia870.iabinary import iabinary

    if oper == '==': y = (f1 == f2)
    elif oper == '~=': y = (f1 != f2)
    elif oper == '<=': y = (f1 <= f2)
    elif oper == '>=': y = (f1 >= f2)
    elif oper == '>': y = (f1 > f2)
    elif oper == '<': y = (f1 < f2)
    else:
        assert 0, 'oper must be one of: ==, ~=, >, >=, <, <=, it was:' + oper
    if oper1 != None:
        if oper1 == '==': y = iaintersec(y, f2 == f3)
        elif oper1 == '~=': y = iaintersec(y, f2 != f3)
        elif oper1 == '<=': y = iaintersec(y, f2 <= f3)
        elif oper1 == '>=': y = iaintersec(y, f2 >= f3)
        elif oper1 == '>': y = iaintersec(y, f2 > f3)
        elif oper1 == '<': y = iaintersec(y, f2 < f3)
        else:
            assert 0, 'oper1 must be one of: ==, ~=, >, >=, <, <=, it was:' + oper1

    y = iabinary(y)

    return y
Beispiel #7
0
def iasupcanon(f, Iab, theta=45, DIRECTION="CLOCKWISE"):
    from ia870.iaintersec import iaintersec
    from ia870.iainterot import iainterot
    from ia870.iaunion import iaunion
    from ia870.iasupgen import iasupgen

    DIRECTION = DIRECTION.upper()
    y = iaintersec(f, 0)
    for t in range(0, 360, theta):
        Irot = iainterot(Iab, t, DIRECTION)
        y = iaunion(y, iasupgen(f, Irot))

    return y
Beispiel #8
0
def iaskelmrec(f, B=None):
    from ia870.iabinary import iabinary
    from ia870.iaintersec import iaintersec
    from ia870.iadil import iadil
    from ia870.iaunion import iaunion
    from ia870.iasecross import iasecross
    if B is None:
        B = iasecross(None)

    y = iabinary(iaintersec(f, 0))
    for r in range(max(ravel(f)), 1, -1):
        y = iadil(iaunion(y, iabinary(f, r)), B)
    y = iaunion(y, iabinary(f, 1))
    return y
Beispiel #9
0
def iaintershow(Iab):
    from ia870.iaseunion import iaseunion
    from ia870.iaintersec import iaintersec

    assert (type(Iab) is tuple) and (
        len(Iab) == 2), 'not proper fortmat of hit-or-miss template'
    A, Bc = Iab
    S = iaseunion(A, Bc)
    Z = iaintersec(S, 0)
    n = product(S.shape)
    one = reshape(array(n * '1', 'c'), S.shape)
    zero = reshape(array(n * '0', 'c'), S.shape)
    x = reshape(array(n * '.', 'c'), S.shape)
    saux = choose(S + iaseunion(Z, A), (x, zero, one))

    return '\n'.join([ss.tostring().decode() for ss in saux])
Beispiel #10
0
def iainpos(f, g, bc=iasecross()):
    from ia870.iaisbinary import iaisbinary
    from ia870.iagray import iagray
    from ia870.ianeg import ianeg
    from ia870.iadatatype import iadatatype
    from ia870.ialimits import ialimits
    from ia870.iasuprec import iasuprec
    from ia870.iaintersec import iaintersec
    from ia870.iaunion import iaunion

    assert iaisbinary(f), 'First parameter must be binary image'
    fg = iagray(ianeg(f), iadatatype(g))
    k1 = ialimits(g)[1] - 1
    y = iasuprec(fg, iaintersec(iaunion(g, 1), k1, fg), bc)

    return y
Beispiel #11
0
def iacbisector(f, B, n):
    from ia870.iaintersec import iaintersec
    from ia870.iasesum import iasesum
    from ia870.iaero import iaero
    from ia870.iacdil import iacdil
    from ia870.iasubm import iasubm
    from ia870.iaunion import iaunion

    y = iaintersec(f, 0)
    for i in range(n):
        nb = iasesum(B, i)
        nbp = iasesum(B, i + 1)
        f1 = iaero(f, nbp)
        f2 = iacdil(f1, f, B, n)
        f3 = iasubm(iaero(f, nb), f2)
        y = iaunion(y, f3)
    return y
Beispiel #12
0
def iagdist(f, g, Bc=iasecross(), METRIC=None):
    from ia870.ianeg import ianeg
    from ia870.iagray import iagray
    from ia870.iaintersec import iaintersec
    from ia870.iaisequal import iaisequal
    from ia870.iacero import iacero
    from ia870.iaaddm import iaaddm
    from ia870.iaunion import iaunion

    assert METRIC is None, 'Does not support EUCLIDEAN'
    fneg, gneg = ianeg(f), ianeg(g)
    y = iagray(gneg, 'uint16', 1)
    ero = iaintersec(y, 0)
    aux = y
    i = 1
    while (ero != aux).any():
        aux = ero
        ero = iacero(gneg, fneg, Bc, i)
        y = iaaddm(y, iagray(ero, 'uint16', 1))
        i = i + 1
    y = iaunion(y, iagray(ero, 'uint16'))

    return y