-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcal_data+empty .py
91 lines (58 loc) · 1.68 KB
/
cal_data+empty .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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 17 11:27:45 2022
@author: Jason
分別畫出有細胞的玻片 以及,空白玻片的光譜圖像並且疊加
"""
import os
from spectral.io import envi
import spectral
# os.chdir(r'C:\Users\Jason\Documents\HinaLea\SDKtest\bin\processed\20200521_101240')
spectral.settings.envi_support_nonlowercase_params ='TRUE'
#光譜將具有CxB形狀,其中C是庫中的光譜數,B是每個光譜的譜帶數。
os.chdir(r"H:\臺大醫院測試\第9次拍攝\700\sample 700")
img = envi.open("sample 700.hdr", "sample 700.dat")
print(img.__class__)
print(img)
print('===================================')
arr = img.load()
arr.__class__
print (arr.info())
print(arr.shape) #608 x968 x299
#%%
sample700 =[]
for i in range(0,608):
for j in range(0,968):
sample700.append(arr[i,j,:].reshape(299))
data = np.zeros(299)
for i in range(len(sample700)):
data = data +sample700[i]
data700 = data/299
plt.plot(data700,label='data')
z = 70
#%%
os.chdir(r"H:\臺大醫院測試\第9次拍攝\700\empty 700")
img1 = envi.open("empty 700.hdr", "empty 700.dat")
arr1 = img1.load()
empty700 =[]
for i in range(0,608):
for j in range(0,968):
empty700.append(arr1[i,j,:].reshape(299))
data1 = np.zeros(299)
for i in range(len(empty700)):
data1 = data1 +empty700[i]
empty700 = data1/299
plt.plot(empty700,label='empty')
plt.legend()
plt.xlabel('Number of bands')
plt.ylabel('Intensity')
plt.title('500ms')
vlines(z, 0,data700.max(),'r')
#%%
plt.figure()
index = data700/empty700
plt.plot(index)
plt.xlabel('Number of bands')
plt.ylabel('Intensity')
plt.title('500ms')
vlines(z, index.min(),index.max(),'r')