-
Notifications
You must be signed in to change notification settings - Fork 1
/
tsne1.py
51 lines (39 loc) · 1.06 KB
/
tsne1.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
44
45
46
47
48
49
50
51
# tsne1.py
from PIL import Image
from matplotlib import pyplot as plt
import glob
import numpy as np
from tsne import bh_sne
import code
import imgDisplay
from IPython import embed
def tSNE (x_data, display_plot=False):
vis_data = bh_sne(x_data)# tsne embedding
vis_x = vis_data[:, 0]
vis_y = vis_data[:, 1]
if display_plot:
plt.scatter(vis_x, vis_y, c = 'black')
plt.show()
'''
images = []
image_size = 70
plot_size = 1000
canvas = imgDisplay.image_scatter(x_data, x_data, image_size, plot_size)
plt.ion() # maybe not needed? for actually seeing what is imshow'ed
plt.imshow(canvas)
plt.show(block=False) # actually show the image
'''
'''
filenames= glob.glob('croppedCell*.jpg')
for filename in filenames:
print filename
im=Image.open(filenames[0])
im=np.array(im)
images.append(im)
plt.imshow(im)
code.interact(local=dict(globals(), **locals()))
raw_input("press enter..")
if __name__ == '__main__':
plt.ion()
tsne()
'''