示例#1
0
def iais(f1, oper, f2=None, oper1=None, f3=None):
    from iaisbinary import iaisbinary
    from iaisequal import iaisequal
    from iaislesseq import iaislesseq
    from ianeg import ianeg
    from iathreshad import iathreshad
    from iabinary import iabinary


    if f2 == None:
        oper=upper(oper);
        if   oper == 'BINARY': return iaisbinary(f1)
        elif oper == 'GRAY'  : return not iaisbinary(f1)
        else:
            assert 0,'oper should be BINARY or GRAY, was'+oper
    elif oper == '==':    y = iaisequal(f1, f2)
    elif oper == '~=':    y = not iaisequal(f1,f2)
    elif oper == '<=':    y = iaislesseq(f1,f2)
    elif oper == '>=':    y = iaislesseq(f2,f1)
    elif oper == '>':     y = iaisequal( ianeg( iathreshad(f2,f1)),iabinary(1))
    elif oper == '<':     y = iaisequal( ianeg( iathreshad(f1,f2)),iabinary(1))
    else:
        assert 0,'oper must be one of: ==, ~=, >, >=, <, <=, it was:'+oper
    if oper1 != None:
        if   oper1 == '==': y = y and iaisequal(f2,f3)
        elif oper1 == '~=': y = y and (not iaisequal(f2,f3))
        elif oper1 == '<=': y = y and iaislesseq(f2,f3)
        elif oper1 == '>=': y = y and iaislesseq(f3,f2)
        elif oper1 == '>':  y = y and iaisequal( ianeg( iathreshad(f3,f2)),iabinary(1))
        elif oper1 == '<':  y = y and iaisequal( ianeg( iathreshad(f2,f3)),iabinary(1))
        else:
            assert 0,'oper1 must be one of: ==, ~=, >, >=, <, <=, it was:'+oper1


    return y
示例#2
0
文件: iaclohole.py 项目: DiJei/ia870
def iaclohole(f, Bc=iasecross()):
    from iaframe import iaframe
    from ianeg import ianeg
    from iainfrec import iainfrec

    delta_f = iaframe(f)
    return ianeg( iainfrec( delta_f, ianeg(f), Bc))
示例#3
0
def iaclohole(f, Bc=iasecross()):
    from iaframe import iaframe
    from ianeg import ianeg
    from iainfrec import iainfrec

    delta_f = iaframe(f)
    return ianeg(iainfrec(delta_f, ianeg(f), Bc))
示例#4
0
def iaero(f, b=None):
    from ianeg import ianeg
    from iadil import iadil
    from iasereflect import iasereflect
    from iasecross import iasecross

    if b is None: b = iasecross()
    y = ianeg(iadil(ianeg(f), iasereflect(b)))
    return y
示例#5
0
文件: iaero.py 项目: ramosapf/ia870
def iaero(f, b=None):
    from ianeg import ianeg
    from iadil import iadil
    from iasereflect import iasereflect
    from iasecross import iasecross

    if b is None:
        b = iasecross()
    y = ianeg(iadil(ianeg(f), iasereflect(b)))
    return y
示例#6
0
文件: iais.py 项目: ramosapf/ia870
def iais(f1, oper, f2=None, oper1=None, f3=None):
    from iaisbinary import iaisbinary
    from iaisequal import iaisequal
    from iaislesseq import iaislesseq
    from ianeg import ianeg
    from iathreshad import iathreshad
    from iabinary import iabinary

    if f2 == None:
        oper = upper(oper)
        if oper == "BINARY":
            return iaisbinary(f1)
        elif oper == "GRAY":
            return not iaisbinary(f1)
        else:
            assert 0, "oper should be BINARY or GRAY, was" + oper
    elif oper == "==":
        y = iaisequal(f1, f2)
    elif oper == "~=":
        y = not iaisequal(f1, f2)
    elif oper == "<=":
        y = iaislesseq(f1, f2)
    elif oper == ">=":
        y = iaislesseq(f2, f1)
    elif oper == ">":
        y = iaisequal(ianeg(iathreshad(f2, f1)), iabinary(1))
    elif oper == "<":
        y = iaisequal(ianeg(iathreshad(f1, f2)), iabinary(1))
    else:
        assert 0, "oper must be one of: ==, ~=, >, >=, <, <=, it was:" + oper
    if oper1 != None:
        if oper1 == "==":
            y = y and iaisequal(f2, f3)
        elif oper1 == "~=":
            y = y and (not iaisequal(f2, f3))
        elif oper1 == "<=":
            y = y and iaislesseq(f2, f3)
        elif oper1 == ">=":
            y = y and iaislesseq(f3, f2)
        elif oper1 == ">":
            y = y and iaisequal(ianeg(iathreshad(f3, f2)), iabinary(1))
        elif oper1 == "<":
            y = y and iaisequal(ianeg(iathreshad(f2, f3)), iabinary(1))
        else:
            assert 0, "oper1 must be one of: ==, ~=, >, >=, <, <=, it was:" + oper1

    return y
示例#7
0
def iagshow(X, X1=None, X2=None, X3=None, X4=None, X5=None, X6=None):
    from iaisbinary import iaisbinary
    from iagray import iagray
    from iaunion import iaunion
    from iaintersec import iaintersec
    from ianeg import ianeg
    from iaconcat import iaconcat

    if iaisbinary(X): X = iagray(X, 'uint8')
    r = X
    g = X
    b = X
    if X1 is not None:  # red 1 0 0
        assert iaisbinary(X1), 'X1 must be binary overlay'
        x1 = iagray(X1, 'uint8')
        r = iaunion(r, x1)
        g = iaintersec(g, ianeg(x1))
        b = iaintersec(b, ianeg(x1))
    if X2 is not None:  # green 0 1 0
        assert iaisbinary(X2), 'X2 must be binary overlay'
        x2 = iagray(X2, 'uint8')
        r = iaintersec(r, ianeg(x2))
        g = iaunion(g, x2)
        b = iaintersec(b, ianeg(x2))
    if X3 is not None:  # blue 0 0 1
        assert iaisbinary(X3), 'X3 must be binary overlay'
        x3 = iagray(X3, 'uint8')
        r = iaintersec(r, ianeg(x3))
        g = iaintersec(g, ianeg(x3))
        b = iaunion(b, x3)
    if X4 is not None:  # magenta 1 0 1
        assert iaisbinary(X4), 'X4 must be binary overlay'
        x4 = iagray(X4, 'uint8')
        r = iaunion(r, x4)
        g = iaintersec(g, ianeg(x4))
        b = iaunion(b, x4)
    if X5 is not None:  # yellow 1 1 0
        assert iaisbinary(X5), 'X5 must be binary overlay'
        x5 = iagray(X5, 'uint8')
        r = iaunion(r, x5)
        g = iaunion(g, x5)
        b = iaintersec(b, ianeg(x5))
    if X6 is not None:  # cyan 0 1 1
        assert iaisbinary(X6), 'X6 must be binary overlay'
        x6 = iagray(X6, 'uint8')
        r = iaintersec(r, ianeg(x6))
        g = iaunion(g, x6)
        b = iaunion(b, x6)
    return iaconcat('d', r, g, b)
    return Y
示例#8
0
文件: iagshow.py 项目: DiJei/ia870
def iagshow(X, X1=None, X2=None, X3=None, X4=None, X5=None, X6=None):
    from iaisbinary import iaisbinary
    from iagray import iagray
    from iaunion import iaunion
    from iaintersec import iaintersec
    from ianeg import ianeg
    from iaconcat import iaconcat

    if iaisbinary(X): X = iagray(X,'uint8')
    r = X
    g = X
    b = X
    if X1 is not None: # red 1 0 0
      assert iaisbinary(X1),'X1 must be binary overlay'
      x1 = iagray(X1,'uint8')
      r = iaunion(r,x1)
      g = iaintersec(g,ianeg(x1))
      b = iaintersec(b,ianeg(x1))
    if X2 is not None: # green 0 1 0
      assert iaisbinary(X2),'X2 must be binary overlay'
      x2 = iagray(X2,'uint8')
      r = iaintersec(r,ianeg(x2))
      g = iaunion(g,x2)
      b = iaintersec(b,ianeg(x2))
    if X3 is not None: # blue 0 0 1
      assert iaisbinary(X3),'X3 must be binary overlay'
      x3 = iagray(X3,'uint8')
      r = iaintersec(r,ianeg(x3))
      g = iaintersec(g,ianeg(x3))
      b = iaunion(b,x3)
    if X4 is not None: # magenta 1 0 1
      assert iaisbinary(X4),'X4 must be binary overlay'
      x4 = iagray(X4,'uint8')
      r = iaunion(r,x4)
      g = iaintersec(g,ianeg(x4))
      b = iaunion(b,x4)
    if X5 is not None: # yellow 1 1 0
      assert iaisbinary(X5),'X5 must be binary overlay'
      x5 = iagray(X5,'uint8')
      r = iaunion(r,x5)
      g = iaunion(g,x5)
      b = iaintersec(b,ianeg(x5))
    if X6 is not None: # cyan 0 1 1
      assert iaisbinary(X6),'X6 must be binary overlay'
      x6 = iagray(X6,'uint8')
      r = iaintersec(r,ianeg(x6))
      g = iaunion(g,x6)
      b = iaunion(b,x6)
    return iaconcat('d',r,g,b)
    return Y
示例#9
0
def iainfgen(f, Iab):
    from iaunion import iaunion
    from iadil import iadil
    from ianeg import ianeg

    A, Bc = Iab
    y = iaunion(iadil(f, A), iadil(ianeg(f), Bc))

    return y
示例#10
0
def iasupgen(f, INTER):
    from iaintersec import iaintersec
    from iaero import iaero
    from ianeg import ianeg


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

    return y
示例#11
0
def iacrop(f, side='all', color='black'):
    from ianeg import ianeg


    f = asarray(f)
    if len(f.shape) == 1: f = f[newaxis,:]
    if color == 'white': f = ianeg(f)

    aux1, aux2 = sometrue(f,0), sometrue(f,1)
    col, row = flatnonzero(aux1), flatnonzero(aux2)

    #if (not col) and (not row):
    #    return None

    if   side == 'left':   g = f[:, col[0]::]
    elif side == 'right':  g = f[:, 0:col[-1]+1]
    elif side == 'top':    g = f[row[0]::, :]
    elif side == 'bottom': g = f[0:row[-1]+1, :]
    else:                  g = f[row[0]:row[-1]+1, col[0]:col[-1]+1]

    if color == 'white': g = ianeg(g)
    return g
示例#12
0
def iagdist(f, g, Bc=iasecross(), METRIC=None):
    from ianeg import ianeg
    from iagray import iagray
    from iaintersec import iaintersec
    from iaisequal import iaisequal
    from iacero import iacero
    from iaaddm import iaaddm
    from 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
示例#13
0
文件: iagdist.py 项目: DiJei/ia870
def iagdist(f, g, Bc=iasecross(), METRIC=None):
    from ianeg import ianeg
    from iagray import iagray
    from iaintersec import iaintersec
    from iaisequal import iaisequal
    from iacero import iacero
    from iaaddm import iaaddm
    from 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
示例#14
0
def iatoggle(f, f1, f2, OPTION="GRAY"):
    from iabinary import iabinary
    from iasubm import iasubm
    from iagray import iagray
    from iaunion import iaunion
    from iaintersec import iaintersec
    from ianeg import ianeg

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

    return y
示例#15
0
文件: iatoggle.py 项目: DiJei/ia870
def iatoggle(f, f1, f2, OPTION="GRAY"):
    from iabinary import iabinary
    from iasubm import iasubm
    from iagray import iagray
    from iaunion import iaunion
    from iaintersec import iaintersec
    from ianeg import ianeg


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


    return y
示例#16
0
def iainpos(f, g, bc=iasecross()):
    from iaisbinary import iaisbinary
    from iagray import iagray
    from ianeg import ianeg
    from iadatatype import iadatatype
    from ialimits import ialimits
    from iasuprec import iasuprec
    from iaintersec import iaintersec
    from 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
示例#17
0
文件: iainpos.py 项目: DiJei/ia870
def iainpos(f, g, bc=iasecross()):
    from iaisbinary import iaisbinary
    from iagray import iagray
    from ianeg import ianeg
    from iadatatype import iadatatype
    from ialimits import ialimits
    from iasuprec import iasuprec
    from iaintersec import iaintersec
    from 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
示例#18
0
def iase2interval(a, b):
    from ianeg import ianeg

    Iab = (a,ianeg(b))
    return Iab
示例#19
0
def iaareaclose(f, a, Bc=iasecross()):
    from ianeg import ianeg
    from iaareaopen import iaareaopen

    y = ianeg( iaareaopen( ianeg(f),a,Bc))
    return y
示例#20
0
def iaareaclose(f, a, Bc=iasecross()):
    from ianeg import ianeg
    from iaareaopen import iaareaopen

    y = ianeg( iaareaopen( ianeg(f),a,Bc))
    return y