-
Notifications
You must be signed in to change notification settings - Fork 0
/
exp.py
80 lines (64 loc) · 3.04 KB
/
exp.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Feb 2019 @author: Rui ZHAO
The following code corresponds to the experiment sections (sec 3.3, 3.4 and 3.5) of our paper:
R Zhao, Z Shi, Z Zou, Z Zhang, Ensemble-Based Cascaded Constrained Energy Minimization for Hyperspectral Target Detection. Remote Sensing 2019.
"""
from utils import Data
from e_cem import ECEM
from detector_zoo import Detectors as Other_detectors
class Exp(object):
def __init__(self):
self.data = []
def san(self):
self.data = Data('hyperspectral_data//san.mat') # load data
ecem = ECEM()
ecem.parmset(**{'windowsize': [1 / 4, 2 / 4, 3 / 4, 4 / 4], # window size
'num_layer': 10, # the number of detection layers
'num_cem': 6, # the number of CEMs per layer
'Lambda': 1e-6, # the regularization coefficient
'show_proc': True}) # show the process or not
return ecem
def san_noise(self, snr=20):
self.data = Data('hyperspectral_data//san.mat', snr) # load data with white Gaussian noise (SNR=20 or 25)
ecem = ECEM()
ecem.parmset(**{'windowsize': [1 / 4, 2 / 4, 3 / 4, 4 / 4], # window size
'num_layer': 10, # the number of detection layers
'num_cem': 6, # the number of CEMs per layer
'Lambda': 6e-2, # the regularization coefficient
'show_proc': True}) # show the process or not
return ecem
def syn_noise(self, snr=20):
ecem = ECEM()
ecem.parmset(**{'windowsize': [1 / 4, 2 / 4, 3 / 4, 4 / 4], # window size
'num_layer': 10, # the number of detection layers
'num_cem': 6, # the number of CEMs per layer
'Lambda': 5e-3, # the regularization coefficient
'show_proc': True}) # show the process or not
return ecem
def cup(self):
self.data = Data('hyperspectral_data//cup.mat') # load data with noise
ecem = ECEM()
ecem.parmset(**{'windowsize': [1 / 4, 2 / 4, 3 / 4, 4 / 4], # window size
'num_layer': 10, # the number of detection layers
'num_cem': 6, # the number of CEMs per layer
'Lambda': 1e-1, # the regularization coefficient
'show_proc': True}) # show the process or not
return ecem
def main():
exp = Exp()
# chose an experiment: san (sec 3.4), san_noise (sec 3.4), syn_noise (sec 3.3), or cup (sec 3.5)
ecem = exp.san()
results = []
names = []
for name, detector in Other_detectors().detect(exp.data).items(): # dectection
print('detector:' + name)
results.append(detector())
names.append(name)
print('detector:' + 'E-CEM')
results.append(ecem.detect(exp.data, pool_num=4)) # dectection
names.append('E-CEM')
ecem.show(results, names) # show
if __name__ == '__main__':
main()