-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.m
executable file
·93 lines (70 loc) · 2.48 KB
/
main.m
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
91
92
93
%--------------------------------------------------------------------------
% Copyright @ Carlos Hinojosa, 2018
%--------------------------------------------------------------------------
%% Clear Screen and Workspace
clear all
close all
clc
verbose = true;
%% Choose Architecture
% 1: GPU Single
% 2: GPU Double
% 3: CPU
arch = 1;
%% Add Hyperspectral databases and auxiliary codes to the path
addpath('./DataBases');
addpath('./Auxiliary Files/');
addpath('./Coding Patterns Design/');
%% Select and load the database
Fname = 'UPavia_Subset';
database = 'UPavia_Subset';
fprintf(['Experiment start at: ',datestr(datetime('now')),'\n'])
fprintf('=======================================================\n');
fprintf('Loading hyperspectral datacue and preparing data \n');
fprintf('=======================================================\n');
load(database);
hyperimg = paviaU; %Set Hyperspectral image
hyperimg_gt = paviaU_gt; %Set Hyperspectral image groundtruth
%if verbose true show Fig 7
[M,N,L]=size(hyperimg);
s = hyperimg_gt(:);
%% Reshape the data cube to LxMN matrix
Xfull=reshape(hyperimg,M*N,L);
Xfull=Xfull';
%% Set coded aperture design parameters
shots =25; %Measurement shots
delta = 10; %Bandpass filters bandwidth
designed = 1; % 1 = Use designed codes, 0 = use random codes
noise = 25; % Noise added
%% Sparse Subspace Clustering parameters
l = 8;% number of clusters
% Original SSC parameters
alpha = [1000,300];
r = 0; % data projection
affine = true; % affine constraint
outlier = false; % data has outlier
rho = 0.7;
la = 7.76e-7; % sparsity/noise tradeoff
% Spatial information regularization parameter
alphass = 8500;
%% Compressive Spectral Imaging (CSI) acquisition
fprintf('Acquiring compressed measurements \n');
fprintf('=======================================================\n');
Phi = generateCodes(L,shots,delta,designed);
% Acquire the compressed measurements
X = Phi*Xfull;
%if verbose true show compressed data
% Add noise to the measurements
if noise>0
X = awgn(X,noise,'measured');
end
% Data normalization
X = X.*sqrt(delta/shots);
%% Compressed Sparse Subspace Clustering With Spatial Regularizer
[results,C,img] = CSI_SSC(X,r,affine,alpha,outlier,rho,s,l,la,alphass,M,N,Fname,arch);
% Recolecting results
Res = {results, img};
parameters = {shots,delta,noise,l,alpha,rho,la,alphass};
results = {Res,Phi,parameters};
fprintf(['Experiment ends at: ',datestr(datetime('now')),'\n'])
fprintf('=======================================================\n');