def iaareaclose(f, a, Bc=None): from ia870 import ianeg,iaareaopen,iasecross if Bc is None: Bc = iasecross() y = ianeg( iaareaopen( ianeg(f),a,Bc)) return y
def timg(f): tFalse = t(' ') dy, dx = tFalse.shape tTrue = np.zeros_like(tFalse) z = np.empty(tuple(np.array(f.shape) * np.array([dy, dx]))).astype(bool) if f.dtype == 'bool': for x in np.arange(f.shape[-1]): for y in np.arange(f.shape[-2]): if f[y, x]: z[y * dy:y * dy + dy, x * dx:x * dx + dx] = tFalse else: z[y * dy:y * dy + dy, x * dx:x * dx + dx] = tTrue z = ia.ianeg(np.pad(z, ((1, 1), (1, 1)), 'constant')) else: for x in np.arange(f.shape[-1]): for y in np.arange(f.shape[-2]): z[y * dy:y * dy + dy, x * dx:x * dx + dx] = t('%3d' % f[y, x]) z = np.pad(ia.ianeg(z), ((1, 1), (1, 1)), 'constant') return z
def iagshow(X, X1=None, X2=None, X3=None, X4=None, X5=None, X6=None): from ia870 import iaisbinary, iagray, iaunion from ia870 import iaintersec, ianeg, 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 np.array([r, g, b]) return Y
def ianshow(X, X1=None, X2=None, X3=None, X4=None, X5=None, X6=None): x = timg(X) x1, x2, x3, x4, x5, x6 = None, None, None, None, None, None if X1 is not None: x1 = ia.iadil(ia.ianeg(timg(X1))) if X2 is not None: x2 = ia.iadil(ia.ianeg(timg(X2))) if X3 is not None: x3 = ia.iadil(ia.ianeg(timg(X3))) if X4 is not None: x4 = ia.iadil(ia.ianeg(timg(X4))) if X5 is not None: x5 = ia.iadil(ia.ianeg(timg(X5))) if X6 is not None: x6 = ia.iadil(ia.ianeg(timg(X6))) return ia.iagshow(x, x1, x2, x3, x4, x5, x6)
def iaero(f, b=None): from ia870 import ianeg, iadil, iasereflect, iasecross if b is None: b = iasecross() y = ianeg(iadil(ianeg(f), iasereflect(b))) return y