out_fname = "patches-%d-dog" % size if options.mf: out_fname += "-mf" if options.norm: out_fname += "-norm" if options.varnorm: out_fname += "-varnorm" # print "Input file: %s" % in_fname print "Output file: %s" % out_fname print "# of patches: %d" % N_patches print "Patch size : %d x %d" % (size, size) # Create output file tbl_out = AutoTable(out_fname + ".h5") # Size magic left = (oversize // 2) - (size // 2) right = left + size #============================================================ # Start to do some real work batch_size = 1000 dog = DoG(1., 3., 9) for n in xrange(0, N_patches): if n % batch_size == 0: dlog.progress("Preprocessing...", n / N_patches) P = in_oversized[n, :, :]
out_fname = "patches-%d-dog" % size if options.mf: out_fname += "-mf" if options.norm: out_fname += "-norm" if options.varnorm: out_fname += "-varnorm" # print "Input file: %s" % in_fname print "Output file: %s" % out_fname print "# of patches: %d" % N_patches print "Patch size : %d x %d" % (size, size) # Create output file tbl_out = AutoTable(out_fname+".h5") # Size magic left = (oversize // 2)-(size //2) right = left + size #============================================================ # Start to do some real work batch_size = 1000 dog = DoG(1., 3., 9) for n in xrange(0, N_patches): if n % batch_size == 0: dlog.progress("Preprocessing...", n/N_patches) P = in_oversized[n,:,:]
out_fname = "patches-%d-zca3" % size if options.mf: out_fname += "-mf" if options.norm: out_fname += "-norm" if options.varnorm: out_fname += "-varnorm" # print "Input file: %s" % in_fname print "Output file: %s" % out_fname print "# of patches: %d" % N_patches print "Patch size : %d x %d" % (size, size) # Create output file tbl_out = AutoTable(out_fname + ".h5") # Internal parameters batch_size = 1000 epsilon = 1e-3 D = size**2 dim = D #============================================================ # Start to do some real work dlog.progress("Loading patches...") P = in_patches[:N_patches, :, :].reshape(N_patches, -1) P_mean = P.mean(axis=0) # Create covariance matrix
out_fname = "patches-%d-zca3" % size if options.mf: out_fname += "-mf" if options.norm: out_fname += "-norm" if options.varnorm: out_fname += "-varnorm" # print "Input file: %s" % in_fname print "Output file: %s" % out_fname print "# of patches: %d" % N_patches print "Patch size : %d x %d" % (size, size) # Create output file tbl_out = AutoTable(out_fname+".h5") # Internal parameters batch_size = 1000 epsilon = 1e-3 D = size**2 dim = D #============================================================ # Start to do some real work dlog.progress("Loading patches...") P = in_patches[:N_patches,:,:].reshape(N_patches, -1) P_mean = P.mean(axis=0) # Create covariance matrix
#============================================================================= if __name__ == "__main__": if len(sys.argv) != 3: print "Usage: %s <images.h5> <size>" % sys.argv[0] exit(1) images_fname = sys.argv[1] size = int(sys.argv[2]) oversize = 2*size N_patches = 1000000 min_var = 0.0001 out_fname = "patches-%d" % size out_tbl = AutoTable(out_fname+".h5") images_h5 = tables.openFile(images_fname, "r") images = images_h5.root.images N_images = images.shape[0] #ppi = (N_patches // N_images // 10) + 1 ppi = 4 for n in xrange(N_patches): if n % 1000 == 0: dlog.progress("Extracting patch %d" % n, n/N_patches) if n % ppi == 0: while True: img = images[np.random.randint(N_images)] img = img / img.max()
import pulp.preproc.image as pri #============================================================================= if __name__ == "__main__": if len(sys.argv) != 3: print "Usage: %s <images.h5> <size>" % sys.argv[0] exit(1) images_fname = sys.argv[1] size = int(sys.argv[2]) oversize = 2 * size N_patches = 1000000 min_var = 0.0001 out_fname = "patches-%d" % size out_tbl = AutoTable(out_fname + ".h5") images_h5 = tables.openFile(images_fname, "r") images = images_h5.root.images N_images = images.shape[0] #ppi = (N_patches // N_images // 10) + 1 ppi = 4 for n in xrange(N_patches): if n % 1000 == 0: dlog.progress("Extracting patch %d" % n, n / N_patches) if n % ppi == 0: while True: img = images[np.random.randint(N_images)] img = img / img.max()