def iadist(f, Bc=iasecross(), METRIC=None): from iagray import iagray from iaintersec import iaintersec from iaisequal import iaisequal from iaero import iaero from iasebox import iasebox if METRIC is not None: METRIC = upper(METRIC) f = iagray(f, "uint16") y = iaintersec(f, 0) if (METRIC == "EUCLIDEAN") or (METRIC == "EUC2"): f = int32(f) b = int32(zeros((3, 3))) i = 1 while any(f != y): a4, a2 = -4 * i + 2, -2 * i + 1 b = int32([[a4, a2, a4], [a2, 0, a2], [a4, a2, a4]]) y = f i = i + 1 f = iaero(f, b) if METRIC == "EUCLIDEAN": y = uint16(sqrt(f) + 0.5) else: if iaisequal(Bc, iasecross()): b = int32([[-2147483647, -1, -2147483647], [-1, 0, -1], [-2147483647, -1, -2147483647]]) elif iaisequal(Bc, iasebox()): b = int32([[-1, -1, -1], [-1, 0, -1], [-1, -1, -1]]) else: b = Bc while any(f != y): y = f f = iaero(f, b) return y
def iadist(f, Bc=iasecross(), METRIC=None): from iagray import iagray from iaintersec import iaintersec from iaisequal import iaisequal from iaero import iaero from iasebox import iasebox if METRIC is not None: METRIC = METRIC.upper() f = iagray(f, 'uint16') y = iaintersec(f, 0) if (METRIC == 'EUCLIDEAN') or (METRIC == 'EUC2'): f = int32(f) b = int32(zeros((3, 3))) i = 1 while any(f != y): a4, a2 = -4 * i + 2, -2 * i + 1 b = int32([[a4, a2, a4], [a2, 0, a2], [a4, a2, a4]]) y = f i = i + 1 f = iaero(f, b) if METRIC == 'EUCLIDEAN': y = uint16(sqrt(f) + 0.5) else: if iaisequal(Bc, iasecross()): b = int32([[-2147483647, -1, -2147483647], [-1, 0, -1], [-2147483647, -1, -2147483647]]) elif iaisequal(Bc, iasebox()): b = int32([[-1, -1, -1], [-1, 0, -1], [-1, -1, -1]]) else: b = Bc while any(f != y): y = f f = iaero(f, b) return y
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
def iaskelm(f, B=iasecross(), option="binary"): from iaisbinary import iaisbinary from ialimits import ialimits from iagray import iagray from iaintersec import iaintersec from iasesum import iasesum from iaero import iaero from iaisequal import iaisequal from iaopenth import iaopenth from iasedil import iasedil from iaunion import iaunion from iabinary import iabinary from iapad import iapad from iaunpad import iaunpad assert iaisbinary(f),'Input binary image only' option = upper(option) 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 iaskelm(f, B=iasecross(), option="binary"): from iaisbinary import iaisbinary from ialimits import ialimits from iagray import iagray from iaintersec import iaintersec from iasesum import iasesum from iaero import iaero from iaisequal import iaisequal from iaopenth import iaopenth from iasedil import iasedil from iaunion import iaunion from iabinary import iabinary from iapad import iapad from iaunpad import iaunpad assert iaisbinary(f), 'Input binary image only' option = upper(option) 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 iacbisector(f, B, n): from iaintersec import iaintersec from iasesum import iasesum from iaero import iaero from iacdil import iacdil from iasubm import iasubm from 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 iacbisector(f, B, n): from iaintersec import iaintersec from iasesum import iasesum from iaero import iaero from iacdil import iacdil from iasubm import iasubm from 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 iaopen(f, b=None): from iadil import iadil from iaero import iaero from iasecross import iasecross if b is None: b = iasecross() y = iadil( iaero(f,b),b) return y
def iagradm(f, Bdil=None, Bero=None): from iasubm import iasubm from iadil import iadil from iaero import iaero from iasecross import iasecross if Bdil is None: Bdil = iasecross() if Bero is None: Bero = iasecross() y = iasubm( iadil(f,Bdil),iaero(f,Bero)) return y
def iaclose(f, b=None): from iaero import iaero from iadil import iadil from iasecross import iasecross if b is None: b = iasecross() y = iaero(iadil(f, b), b) return y
def iacero(f, g, b=iasecross(), n=1): from iaunion import iaunion from iaero import iaero from 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 iacero(f, g, b=iasecross(), n=1): from iaunion import iaunion from iaero import iaero from 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 iaopenrec(f, bero=iasecross(), bc=iasecross()): from iainfrec import iainfrec from iaero import iaero return iainfrec(iaero(f, bero), f, bc)
def iaopenrec(f, bero=iasecross(), bc=iasecross()): from iainfrec import iainfrec from iaero import iaero return iainfrec( iaero(f,bero),f,bc)