forked from ryankemmer/dotsactivity-data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdotgenerator.py
More file actions
64 lines (45 loc) · 1.38 KB
/
dotgenerator.py
File metadata and controls
64 lines (45 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import numpy as np
import matplotlib.pyplot as plt
import os
from itertools import permutations
from itertools import combinations
import json
# Baseline data
Base = 50
area = np.pi*3
masterArray = []
PATH = '/workspaces/dotsactivity-data/tmp'
pictureData = []
os.chdir(PATH)
#each picture per noise level
for j in range(60):
N = Base + j
pictureData.append(N)
existing_locations = []
existing_locations.append(np.array([0,0]))
dots = 0
#add each individual dot
while (dots < N):
x = np.random.rand()
y = np.random.rand()
new_location = np.array([x,y])
valid_checks = 0
#check to ensure new dot is not too close to others
for existing_location in existing_locations:
vecdif = existing_location - new_location
if ((abs(vecdif[0]) < .03) & (abs(vecdif[1]) < .03)):
#print("broke criteria")
break
else:
valid_checks += 1
if valid_checks == len(existing_locations):
dots += 1
existing_locations.append(new_location)
plt.plot(x, y, 'ko')
axes = plt.gca()
axes.set_xlim([-0.02,1.02])
axes.set_ylim([-0.02,1.02])
plt.axes().set_aspect('equal')
plt.axis('off')
plt.savefig(PATH + '/' + str(N),bbox_inches='tight', pad_inches=0)
plt.clf()