Example #1
0
	if m == None:
		return mosaic(images, cols, emptyrows, col)
	elif col == cols:
		return mosaic(images, cols, np.append(m, emptyrows, axis = 0), 0)
	else:
		m[-h:, col*w:col*w+w, :] = i
		return mosaic(images[1:], cols, m, col + 1)

tdb = TinyDB(dimensions = WIDTH * HEIGHT * CHANNELS, parse_args = False)
p = tdb.arg_parser()
p.add_argument("-o", required = True)
p.add_argument("-k", type = int, default = 100)
p.add_argument("-c", type = int, default = 10)
p.add_argument("--seed", type = int, default = -1)
p.add_argument("idx", type = int, nargs = '*')
args = tdb.parse_args()

# number of images
n = tdb.rows()

# if no index is given select indexes at random
idx = []
if len(args.idx) > 0:
	idx = args.idx
else:
	# select a random set of n images
	if args.seed != -1:
		random.seed(args.seed)
	idx = random.sample(xrange(n), args.k)

m = mosaic(images(tdb, idx, WIDTH, HEIGHT, CHANNELS), args.c)
Example #2
0
#!/usr/bin/env python

import cv2
import numpy as np

from tinydb import TinyDB

tdb = TinyDB(parse_args = None)
tdb.arg_parser().add_argument("-o", required = True)
tdb.arg_parser().add_argument("-i", type = int, required = True)
args = tdb.parse_args()

x = np.fromstring(tdb.at(args.i), np.uint8).reshape((32, 32, 3), order = 'F')
r = x[:, :, 0]
g = x[:, :, 1]
b = x[:, :, 2]
x[:, :, 0], x[:, :, 2] = b.copy(), r.copy()

cv2.imwrite(args.o, x)
Example #3
0
#!/usr/bin/env python

from tinydb import TinyDB
from parallel import process

import numpy as np
import scipy.io as sio


db = TinyDB(parse_args = False)
# add additional parameters
db.arg_parser().add_argument("-k", type = int, required = True)
db.arg_parser().add_argument("--rows", type = int, default = 20000)
db.arg_parser().add_argument("-o", required = True)
db.arg_parser().add_argument("--umatrix", required = True)
args = db.parse_args()

# load umatrix

def compute(data):
	

with open(args.o, "w") as f:
	for r in process(db.groups(args.rows), compute):
		f.write(r)

x = rand(5000, 3);
y = (x(:,1) > 0.2) .* (x(:,1) < 0.8) .* (x(:,2) > 0.2) .* (x(:,2) < 0.8) .* (x(:,3) > 0.2) .* (x(:,3) < 0.8);
z = x(y == 0, :)
plot3(z(:,1), z(:,2),z(:,3), 'x', 'color', 'r');