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
def iacero(f, g, b=iasecross(), n=1): from ia870.iaunion import iaunion from ia870.iaero import iaero from ia870.iaisequal import iaisequal y = iaunion(f, g) for i in range(n): aux = y y = iaunion(iaero(y, b), g) if iaisequal(y, aux): break return y
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
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
def iainfgen(f, Iab): from ia870.iaunion import iaunion from ia870.iadil import iadil from ia870.ianeg import ianeg A, Bc = Iab y = iaunion(iadil(f, A), iadil(ianeg(f), Bc)) return y
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
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
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
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
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
def iacthin(f, g, Iab=None, n=-1, theta=45, DIRECTION="CLOCKWISE"): from ia870.iaisbinary import iaisbinary from ia870.iasupgen import iasupgen from ia870.iainterot import iainterot from ia870.iaunion import iaunion from ia870.iasubm import iasubm from ia870.iaisequal import iaisequal from ia870.iahomothin import iahomothin if Iab is None: Iab = iahomothin() DIRECTION = DIRECTION.upper() assert iaisbinary(f), 'f must be binary image' if n == -1: n = product(f.shape) y = f old = y for i in range(n): for t in range(0, 360, theta): sup = iasupgen(y, iainterot(Iab, t, DIRECTION)) y = iaunion(iasubm(y, sup), g) if iaisequal(old, y): break old = y return y
def iasymdif(f1, f2): from ia870.iaunion import iaunion from ia870.iasubm import iasubm y = iaunion(iasubm(f1, f2), iasubm(f2, f1)) return y