-
Notifications
You must be signed in to change notification settings - Fork 0
/
openplotsis.py
54 lines (33 loc) · 1.33 KB
/
openplotsis.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
52
53
54
#!/usr/bin/python3
# -*- coding: utf-8 -*-# -*- coding: utf-8 -*-
import numpy as np
class RawSis():
def __init__(self, filename):
im0, im1, im, raw = self.readsis(filename)
self.im0 = im0
self.im1 = im1
self.im_full = im
self.raw = raw
# self.height, self.width = hw
def readsis(self,filename):
f = open(filename, 'rb') #apre in binario
rawdata = np.fromfile(f,'H').astype(int)
f.close
width=rawdata[6] # N cols
height=rawdata[5] # N rows
#rispetto ad octave, gli indici cambiano (python è 0-based)
image = rawdata[-width*height : ]
image.resize(height,width)
#in matlab, poiché reshape legge per colonne, era necessario scambiare gli indici e poi trasporre la matrice. Ora non più
im0 = image[:height//2, :]
im1 = image[height//2:, :]
return im0, im1, image, rawdata #, image.shape
if __name__ == '__main__':
import sys
import matplotlib.pyplot as plt
sis = RawSis('mainTest.sis')#sys.argv[1])
fig, (ax1, ax2) = plt.subplots(2,1)
dic = {'cmap': 'gist_stern'}
ax1.imshow(sis.im0, **dic)
ax2.imshow(sis.im1, **dic)
fig.show()