-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
34 lines (27 loc) · 987 Bytes
/
script.py
File metadata and controls
34 lines (27 loc) · 987 Bytes
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
import utils
import os
import numpy as np
import matplotlib.pyplot as plt
from algorithms import *
hsi,_,_ = utils.load_HSI("./dataset/Samson.mat") # load Samson Dataset
data = hsi.get_spectra() # Get the hyperspectral observation
A = hsi.get_abundances() # Get the ground truth for the abundances
E = hsi.endmembers # Get the ground truth for the endmembers
n_sources = 3
# Display the hyperspectral observations in the reduced dimension space
Yproj, _ = projection(data.T, n_sources, method='pca')
plt.scatter(Yproj[:, 0], Yproj[:, 1], color='blue')
plt.show()
# Endmember estimation with NFINDR algorithm
nfindr = NFINDR(data.T, n_sources)
nfindr.run()
nfindr.display()
plt.figure()
plt.plot(E[0], '--', color='green', label='Groundtruth')
plt.plot(E[1], '--', color='green')
plt.plot(E[2], '--', color='green')
plt.plot(nfindr.M[:, 0], color='green', label='Estimation')
plt.plot(nfindr.M[:, 1], color='green')
plt.plot(nfindr.M[:, 2], color='green')
plt.legend()
plt.show()