def iasobel(f): import numpy as np from ia636 import iaimginfo, iapconv wx = np.array([[1., 2., 1.], [0., 0., 0.], [-1., -2., -1.]]) wy = np.array([[1., 0., -1.], [2., 0., -2.], [1., 0., -1.]]) gx = iapconv(f, wx) gy = iapconv(f, wy) mag = np.abs(gx + gy * 1j) theta = np.arctan2(gy, gx) return mag, theta
def iasobel(f): import numpy as np from ia636 import iaimginfo, iapconv wx = np.array([[1.,2.,1.], [0.,0.,0.], [-1.,-2.,-1.]]) wy = np.array([[1.,0.,-1.], [2.,0.,-2.], [1.,0.,-1.]]) gx = iapconv(f, wx) gy = iapconv(f, wy) mag = np.abs(gx + gy*1j) theta = np.arctan2(gy,gx) return mag,theta
def iaptrans2(f, t): from ia636 import iapconv f, t = asarray(f), asarray(t).astype(int32) h = zeros(2*abs(t) + 1) t = t + abs(t) h[tuple(t)] = 1 g = iapconv(f, h) return g
def iaptrans2(f, t): from ia636 import iapconv f, t = asarray(f), asarray(t).astype(int32) h = zeros(2 * abs(t) + 1) t = t + abs(t) h[tuple(t)] = 1 g = iapconv(f, h) return g
def iavarfilter(f,h,CV=True): from ia636 import iapconv f = asarray(f).astype(float64) h = asarray(h).astype(bool)[::-1,::-1] n = sum(ravel(h)) h = h/float(n) fm = iapconv(f, h) f2m = iapconv(f**2, h) g = f2m - fm**2 if (CV): fm = fm + 1e-320*(fm == 0) # change zero by a very small number (prevent 'math range error') g[g<0.0] = 0.0 # avoid negative numbers due to numeric precision g = sqrt(g) / fm return g
def iavarfilter(f, h, CV=True): from ia636 import iapconv f = asarray(f).astype(float64) h = asarray(h).astype(bool)[::-1, ::-1] n = sum(ravel(h)) h = h / float(n) fm = iapconv(f, h) f2m = iapconv(f**2, h) g = f2m - fm**2 if (CV): fm = fm + 1e-320 * ( fm == 0 ) # change zero by a very small number (prevent 'math range error') g[g < 0.0] = 0.0 # avoid negative numbers due to numeric precision g = sqrt(g) / fm return g