-
Notifications
You must be signed in to change notification settings - Fork 286
/
Copy pathvar_th.py
41 lines (30 loc) · 1011 Bytes
/
var_th.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
############################################## README #################################################
# This calculates threshold for an image depending upon its spiking activity.
########################################################################################################
import numpy as np
from neuron import neuron
import random
from matplotlib import pyplot as plt
from recep_field import rf
import cv2
from spike_train import encode
from rl import rl
from rl import update
from reconstruct import reconst_weights
from parameters import param as par
import os
def threshold(train):
tu = np.shape(train[0])[0]
thresh = 0
for i in range(tu):
simul_active = sum(train[:,i])
if simul_active>thresh:
thresh = simul_active
return (thresh/3)*par.scale
if __name__ == '__main__':
# img = cv2.imread("mnist1/" + str(1) + ".png", 0)
img = np.array(Image.open("mnist1/" + str(1) + ".png", 0))
print img
# pot = rf(img)
# train = np.array(encode(pot))
# print threshold(train)