deleted unused code
[imago.git] / gridf_analyzer.py
1 import matplotlib.pyplot as plt
2 from matplotlib import cm
3 import time
4 import sys
5 import pickle
6 import multiprocessing
7
8 import gridf
9
10 def job1(args):
11     X, Y, im_l, a, b, c, d, s, v1, k, hough, size = args
12     return [gridf.distance(im_l, 
13                      gridf.get_grid(a + X[y] * s * v1, 
14                               b + Y[y] * s * v1, 
15                               c, d, hough, size),
16                      size) for y in range(2 * k)]
17 def job2(args):
18     X, Y, im_l, a, b, c, d, s, v1, v2, k, hough, size = args
19     return [gridf.distance(im_l, 
20                      gridf.get_grid(a, b, c+ X[y] * s * v2, 
21                               d + Y[y] * s * v2, 
22                               hough, size),
23                      size) for y in range(2 * k)]
24
25 def error_surface(im_l, a, b, c, d, hough, size, v1, v2):
26     X = []
27     Y = []
28     Z = []
29     s = 0.001
30     k = 250
31     for i in range(-k, k):
32         X.append(range(-k, k))
33         Y.append(2*k*[i])
34
35     tasks = [(X[x], Y[x], im_l, a, b, c, d, s, v1, v2, k, hough, size) for x in xrange(0, 2 * k)]
36
37     pool = multiprocessing.Pool(None)
38     
39     start = time.time()
40     Z = pool.map(job2, tasks, 1)
41     print time.time() - start
42
43     s_file = open('surface' + str(k), 'w')
44     pickle.dump((X, Y, Z), s_file)
45     s_file.close()
46     plt.imshow(Z, cmap=cm.jet, interpolation='bicubic', 
47                origin='upper', extent=(-k, k, -k, k), aspect='equal')
48     plt.colorbar()
49
50     plt.show()