-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvg.py
43 lines (30 loc) · 1.31 KB
/
vg.py
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
#This is a video generator for low amplitude flash signals.
import numpy as np
import os
os.chdir('./sample')
for i in range(0,999):
np.random.seed()
#black image
blank = np.zeros((1000, 1000))
#20 targets per image
targets = np.zeros((20,2))
for x in range(0,19):
#create truths
targets[x][0]=np.random.randint(3,997)
targets[x][1]=np.random.randint(3,997)
#apply truthes and a ring around them to the blank image
blank[int(targets[x][0]),int(targets[x][1])] = 2
blank[int(targets[x][0])-1,int(targets[x][1])] = 1
blank[int(targets[x][0])-1,int(targets[x][1]+1)] = 1
blank[int(targets[x][0])-1,int(targets[x][1]-1)] = 1
blank[int(targets[x][0]),int(targets[x][1]-1)] = 1
blank[int(targets[x][0]),int(targets[x][1]+1)] = 1
blank[int(targets[x][0])+1,int(targets[x][1])] = 1
blank[int(targets[x][0])+1,int(targets[x][1]+1)] = 1
blank[int(targets[x][0])+1,int(targets[x][1]-1)] = 1
#apply gaussian noise, not limited to a normal grayscale range
noise = np.random.normal(128,30,(1000,1000))
complete = blank+noise
#save the sample images and truths
np.save('s_'+str(i),complete)
np.save('t_'+str(i),targets)