def Filter2(data): rots = np.array((0, 1, 4, 5, 9)) N = len(rots) V, H = data.shape X = np.zeros((N, V * H), complex) for i in range(len(rots)): r = nd.rotate(data, rots[i], reshape=False) R = ft.fft2(r) X[i] = R.ravel() cst = np.ones(N) filt = fpf.FPF(X, cst, 0.0) return filt
def FudgeFilt(): V = 446 H = 432 X = np.zeros((9, V * H), complex) cst = np.array([1, -1, 1, -1, 1, -1, 1, -1, 1]) for i in range(0, 9): iname = "num2/" + str(i) + "b.png" out = sm.imread(iname, flatten=True) X[i] = ft.fft2(out).ravel() filt = fpf.FPF(X, cst, 0) filt = ft.ifft2(filt.reshape((V, H))) #sm.imsave("filt.png",filt.real) return filt
def MakeFPF(numBoat, cst): V = 148 H = 543 X = np.zeros((numBoat, V * H), complex) #cst = np.array([1,1]) for i in range(0, numBoat): iname = "boat" + str(i + 1) + "bwFilt.png" print("read file ", iname) out = sm.imread(iname, flatten=True) X[i] = ft.fft2(out).ravel() print("X shape", X.shape) filt = fpf.FPF(X, cst, 1) print("X shape", X.shape) filt = ft.ifft2(filt.reshape((V, H))) #sm.imsave("filt.png",filt.real) return filt
def LoadTach(fname, alpha): img = sm.imread(fname, flatten=True) V, H = img.shape X = np.zeros((9, V * H), complex) cst = np.array([1, -1, 1, -1, 1, -1, 1, -1, 1]) #sm.imsave("tach1.png",img) # Read in the nine cutout images of the numbers and make FPF for i in range(0, 9): iname = str(i) + ".png" oname = str(i) + "b.png" #numb = BandW(iname,oname) numb = sm.imread(iname, flatten=True) out = mg.Plop(numb, (V, H)) sm.imsave("numbers\\" + oname, out) X[i] = ft.fft2(out).ravel() filt = fpf.FPF(X, cst, 0) filt = ft.ifft2(filt.reshape((V, H))) #sm.imsave("filt.png",filt.real) return img, filt