-
Notifications
You must be signed in to change notification settings - Fork 2
/
example4.m
576 lines (436 loc) · 18.6 KB
/
example4.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
% =========================================================================
% This code corresponds to the example with the Ivanpah Playa image
% contained in the paper referenced below:
%
% -------------------------------------------------------------------------
% R.A. Borsoi, T. Imbiriba, J.C.M. Bermudez.
% "Super-Resolution for Hyperspectral and Multispectral Image Fusion
% Accounting for Seasonal Spectral Variability"
% IEEE Transactions on Image Processing, 2019.
%
%
% =========================================================================
clear all
close all
clc
addpath(genpath('utils'))
addpath(genpath('FuVar'))
clus = gcp('nocreate'); % If no pool, do not create new one.
if isempty(clus)
c = parcluster('local');
c.NumWorkers = 1; 5;
parpool(c, c.NumWorkers);
end
%%
rng(10, 'twister')
load('DATA/Playa_preproc_subim3_.mat')
R = SRF;
MSim = MSI;
HSim = HSI;
MSp = zeros(size(MSim));
for i=1:size(MSim,3)
x = MSim(:,:,i);
xmax = quantile(x(:),0.999);
% Normalize to 1
x = x/xmax;
MSp(:,:,i) = x;
end
MSI = MSp;
HSp = zeros(size(HSim));
for i=1:size(HSim,3)
x = HSim(:,:,i);
xmax = quantile(x(:),0.999);
%normalize to 1
x = x/xmax;
HSp(:,:,i) = x;
end
HSI = HSp;
% Signal to noise ratio of HS and MS images
SNR_h = 30;
SNR_m = 40;
decimFactor = 4;
H_blur = conv2(ones(decimFactor)/(decimFactor^2), fspecial('gaussian',4,1));
L = size(HSI,3);
L_l = size(MSI,3);
M1 = size(HSI,1);
M2 = size(HSI,2);
N1 = M1/decimFactor;
N2 = M2/decimFactor;
% Get MSI and HR HSI
Ym = MSI;
Zh = denoising(HSI);
% --------------------
% Reorder as an image, blur and downsample to get HSI
Yh = zeros(N1, N2, L);
% degrade each band
for l=1:L
temp = Zh(:,:,l);
temp = imfilter(temp, H_blur, 'symmetric', 'same');
temp = temp(1:decimFactor:end, 1:decimFactor:end);
Yh(:,:,l) = temp;
end
Zh_th = Zh;
% add noise
Yh = Yh + sqrt(sum((Yh(:)).^2)/N1/N2/L/10^(SNR_h/10)) * randn(size(Yh));
Ym = Ym + sqrt(sum((Ym(:)).^2)/M1/M2/L_l/10^(SNR_m/10)) * randn(size(Ym));
% Normalize SRF
R = R ./ repmat(sum(R')',[1 L]);
%%
P = 30;
% % ------------------------------------
% Run VCA on HSI and use FCLS/SCLS for initialization
data_r = (reshape(Yh,N1*N2,L)')';
try
M0 = vca(data_r','Endmembers',P,'verbose','off');
catch
M0 = vca(data_r',P);
end
%% HySure
basis_type = 'VCA';
lambda_phi = 5e-4;
lambda_m = 1;
P_hysure = P;
try
M0_hysure = vca(data_r','Endmembers',P_hysure,'verbose','off');
catch
try
M0_hysure = vca(data_r',P_hysure);
catch
error('Hum... seems like VCA is not working!')
end
end
Yhim = Yh;
Ymim = Ym;
downsamp_factor = decimFactor;
B_est = zeros(M1,M2);
B_est(1:size(H_blur,1), 1:size(H_blur,2)) = H_blur;
shift = 2; % ???
R_est = R;
tic
Z_hysure = data_fusion_mod(Yhim, Ymim, downsamp_factor, R_est, B_est, P_hysure, basis_type, lambda_phi, lambda_m, shift, M0_hysure);
time_hysure = toc;
%% CNMF
% Chose a priori or estimated SRF
R_est = R;
HSI = Yh;
MSI = Ym;
P_cnmf = 40; 40;
tic
Z_cnmf = CNMF_fusion2(HSI,MSI,R_est,P_cnmf);
time_cnmf = toc;
%% GLPHS
hs_glphs = Yh;
ms_glphs = Ym;
ratio_glphs = decimFactor;
mode_glphs = 2;
tic
Z_glphs = MTF_GLP_wrapper(hs_glphs,ms_glphs,ratio_glphs,mode_glphs);
Z_glphs = denoising(Z_glphs);
time_glphs = toc;
%% FuVar algorithm
disp('FuVar...')
% initialization of the spatial coefficients
A_FCLSU = FCLSU(data_r',M0)';
A_init = reshape(A_FCLSU',N1,N2,P);
A_init = imresize(A_init, decimFactor);
A_init = reshape(A_init,M1*M2,P)';
lambda_m = 1;
lambda_a = 1e-4;
lambda_1 = 0.01;
lambda_2 = 10000;
R_srr = R;
tic
Psi_init = ones(L,P);
[Zh,Zm,A,Psi]=FuVar(Yh,Ym,A_init,M0,Psi_init,R_srr,decimFactor,H_blur,...
lambda_m,lambda_a,lambda_1,lambda_2);
time_srr = toc;
Zh_srr = reshape(Zh',M1,M2,L);
Zm_srr = reshape(Zm',M1,M2,L);
%% ------------------------------------
% Reorder data and compute errors
fprintf('\n\n\n--------------------------------------------------------\n')
fprintf('\n\n\n------------------------ times -------------------------\n')
fprintf('Time SRR........: %f \n',time_srr)
fprintf('Time HySure.....: %f \n',time_hysure)
fprintf('Time GLPHS......: %f \n',time_glphs)
fprintf('Time CNMF.......: %f \n',time_cnmf)
qualIdx_srr = QualityIndices_mod(Zh_srr, Zh_th, decimFactor);
qualIdx_hysure = QualityIndices_mod(Z_hysure, Zh_th, decimFactor);
qualIdx_glphs = QualityIndices_mod(Z_glphs, Zh_th, decimFactor);
qualIdx_cnmf = QualityIndices_mod(Z_cnmf, Zh_th, decimFactor);
fprintf('\n\n\n------------------------results ------------------------\n')
fprintf('\n------------------------ PSNR (> better) ---------------\n')
fprintf('Img rec PSNR SRR HS........: %f \n',qualIdx_srr.psnr)
fprintf('Img rec PSNR HySure HS.....: %f \n',qualIdx_hysure.psnr)
fprintf('Img rec PSNR GLPHS HS......: %f \n',qualIdx_glphs.psnr)
fprintf('Img rec PSNR CNMF HS.......: %f \n',qualIdx_cnmf.psnr)
fprintf('\n------------------------ SAM (< better) ----------------\n')
fprintf('Img rec SAM SRR HS........: %f \n',qualIdx_srr.sam)
fprintf('Img rec SAM HySure HS.....: %f \n',qualIdx_hysure.sam)
fprintf('Img rec SAM GLPHS HS......: %f \n',qualIdx_glphs.sam)
fprintf('Img rec SAM CNMF HS.......: %f \n',qualIdx_cnmf.sam)
fprintf('\n------------------------ ERGAS (< better) --------------\n')
fprintf('Img rec ERGAS SRR HS........: %f \n',qualIdx_srr.ergas)
fprintf('Img rec ERGAS HySure HS.....: %f \n',qualIdx_hysure.ergas)
fprintf('Img rec ERGAS GLPHS HS......: %f \n',qualIdx_glphs.ergas)
fprintf('Img rec ERGAS CNMF HS.......: %f \n',qualIdx_cnmf.ergas)
fprintf('\n------------------------ UIQI (> better)----------------\n')
fprintf('Img rec UIQI SRR HS.......: %f \n',qualIdx_srr.uiqi )
fprintf('Img rec UIQI HySure HS....: %f \n',qualIdx_hysure.uiqi )
fprintf('Img rec UIQI GLPHS HS.....: %f \n',qualIdx_glphs.uiqi )
fprintf('Img rec UIQI CNMF HS......: %f \n',qualIdx_cnmf.uiqi )
%%
figure;
[ha, pos] = tight_subplot(1, 5, 0.01, 0.1, 0.1);
% vbands = [57,30,20]; % RGB bands
% vbands = [100 80 50]; % RGB bands
% vbands = [90 30 10]; % RGB bands
vbands = [32 20 8]; % RGB bands --> visible spectra OK!
ddata = Zh_th;
rgbim(:,:,1) = imadjust(rescale(ddata(:,:,vbands(1)),1));
rgbim(:,:,2) = imadjust(rescale(ddata(:,:,vbands(2)),1));
rgbim(:,:,3) = imadjust(rescale(ddata(:,:,vbands(3)),1));
axes(ha(1)); imshow(rgbim); % display RGB image
title('Reference','interpreter','latex')
ddata = Z_hysure;
rgbim(:,:,1) = imadjust(rescale(ddata(:,:,vbands(1)),1));
rgbim(:,:,2) = imadjust(rescale(ddata(:,:,vbands(2)),1));
rgbim(:,:,3) = imadjust(rescale(ddata(:,:,vbands(3)),1));
axes(ha(2)); imshow(rgbim); % display RGB image
title('HySure','interpreter','latex')
ddata = Z_glphs;
rgbim(:,:,1) = imadjust(rescale(ddata(:,:,vbands(1)),1));
rgbim(:,:,2) = imadjust(rescale(ddata(:,:,vbands(2)),1));
rgbim(:,:,3) = imadjust(rescale(ddata(:,:,vbands(3)),1));
axes(ha(3)); imshow(rgbim); % display RGB image
title('GLP-HS','interpreter','latex')
ddata = Z_cnmf;
rgbim(:,:,1) = imadjust(rescale(ddata(:,:,vbands(1)),1));
rgbim(:,:,2) = imadjust(rescale(ddata(:,:,vbands(2)),1));
rgbim(:,:,3) = imadjust(rescale(ddata(:,:,vbands(3)),1));
axes(ha(4)); imshow(rgbim); % display RGB image
title('CNMF','interpreter','latex')
ddata = Zh_srr;
rgbim(:,:,1) = imadjust(rescale(ddata(:,:,vbands(1)),1));
rgbim(:,:,2) = imadjust(rescale(ddata(:,:,vbands(2)),1));
rgbim(:,:,3) = imadjust(rescale(ddata(:,:,vbands(3)),1));
axes(ha(5)); imshow(rgbim); % display RGB image
title('FuVar','interpreter','latex')
% print(['examples/recIm_ex3b_Playa_vis'],'-dpdf')
figure;
[ha, pos] = tight_subplot(1, 5, 0.01, 0.1, 0.1);
vbands = [146 108 46]; % RGB bands --> IR OK!
ddata = Zh_th;
rgbim(:,:,1) = imadjust(rescale(ddata(:,:,vbands(1)),1));
rgbim(:,:,2) = imadjust(rescale(ddata(:,:,vbands(2)),1));
rgbim(:,:,3) = imadjust(rescale(ddata(:,:,vbands(3)),1));
axes(ha(1)); imshow(rgbim); % display RGB image
title('Reference','interpreter','latex')
ddata = Z_hysure;
rgbim(:,:,1) = imadjust(rescale(ddata(:,:,vbands(1)),1));
rgbim(:,:,2) = imadjust(rescale(ddata(:,:,vbands(2)),1));
rgbim(:,:,3) = imadjust(rescale(ddata(:,:,vbands(3)),1));
axes(ha(2)); imshow(rgbim); % display RGB image
title('HySure','interpreter','latex')
ddata = Z_glphs;
rgbim(:,:,1) = imadjust(rescale(ddata(:,:,vbands(1)),1));
rgbim(:,:,2) = imadjust(rescale(ddata(:,:,vbands(2)),1));
rgbim(:,:,3) = imadjust(rescale(ddata(:,:,vbands(3)),1));
axes(ha(3)); imshow(rgbim); % display RGB image
title('GLP-HS','interpreter','latex')
ddata = Z_cnmf;
rgbim(:,:,1) = imadjust(rescale(ddata(:,:,vbands(1)),1));
rgbim(:,:,2) = imadjust(rescale(ddata(:,:,vbands(2)),1));
rgbim(:,:,3) = imadjust(rescale(ddata(:,:,vbands(3)),1));
axes(ha(4)); imshow(rgbim); % display RGB image
title('CNMF','interpreter','latex')
ddata = Zh_srr;
rgbim(:,:,1) = imadjust(rescale(ddata(:,:,vbands(1)),1));
rgbim(:,:,2) = imadjust(rescale(ddata(:,:,vbands(2)),1));
rgbim(:,:,3) = imadjust(rescale(ddata(:,:,vbands(3)),1));
axes(ha(5)); imshow(rgbim); % display RGB image
title('FuVar','interpreter','latex')
% print(['examples/recIm_ex3b_Playa_IR'],'-dpdf')
% ---------------------------------
% repeat in a single figure
figure;
[ha, pos] = tight_subplot(2, 5, [0.01 0.01], 0.35, 0.1);
% vbands = [57,30,20]; % RGB bands
vbands = [32 20 8]; % RGB bands --> visible spectra OK!
ddata = Zh_th;
rgbim(:,:,1) = imadjust(rescale(ddata(:,:,vbands(1)),1));
rgbim(:,:,2) = imadjust(rescale(ddata(:,:,vbands(2)),1));
rgbim(:,:,3) = imadjust(rescale(ddata(:,:,vbands(3)),1));
axes(ha(1)); imshow(rgbim); % display RGB image
set(gca,'xtick',[]), set(gca,'xticklabel',[]), set(gca,'ytick',[]), set(gca,'yticklabel',[])
title('Reference','interpreter','latex')
ddata = Z_hysure;
rgbim(:,:,1) = imadjust(rescale(ddata(:,:,vbands(1)),1));
rgbim(:,:,2) = imadjust(rescale(ddata(:,:,vbands(2)),1));
rgbim(:,:,3) = imadjust(rescale(ddata(:,:,vbands(3)),1));
axes(ha(2)); imshow(rgbim); % display RGB image
set(gca,'xtick',[]), set(gca,'xticklabel',[]), set(gca,'ytick',[]), set(gca,'yticklabel',[])
title('HySure','interpreter','latex')
ddata = Z_glphs;
rgbim(:,:,1) = imadjust(rescale(ddata(:,:,vbands(1)),1));
rgbim(:,:,2) = imadjust(rescale(ddata(:,:,vbands(2)),1));
rgbim(:,:,3) = imadjust(rescale(ddata(:,:,vbands(3)),1));
axes(ha(3)); imshow(rgbim); % display RGB image
set(gca,'xtick',[]), set(gca,'xticklabel',[]), set(gca,'ytick',[]), set(gca,'yticklabel',[])
title('GLP-HS','interpreter','latex')
ddata = Z_cnmf;
rgbim(:,:,1) = imadjust(rescale(ddata(:,:,vbands(1)),1));
rgbim(:,:,2) = imadjust(rescale(ddata(:,:,vbands(2)),1));
rgbim(:,:,3) = imadjust(rescale(ddata(:,:,vbands(3)),1));
axes(ha(4)); imshow(rgbim); % display RGB image
set(gca,'xtick',[]), set(gca,'xticklabel',[]), set(gca,'ytick',[]), set(gca,'yticklabel',[])
title('CNMF','interpreter','latex')
ddata = Zh_srr;
rgbim(:,:,1) = imadjust(rescale(ddata(:,:,vbands(1)),1));
rgbim(:,:,2) = imadjust(rescale(ddata(:,:,vbands(2)),1));
rgbim(:,:,3) = imadjust(rescale(ddata(:,:,vbands(3)),1));
axes(ha(5)); imshow(rgbim); % display RGB image
set(gca,'xtick',[]), set(gca,'xticklabel',[]), set(gca,'ytick',[]), set(gca,'yticklabel',[])
title('FuVar','interpreter','latex')
% vbands = [57,30,20]; % RGB bands
vbands = [146 108 46]; % RGB bands --> IR OK!
ddata = Zh_th;
rgbim(:,:,1) = imadjust(rescale(ddata(:,:,vbands(1)),1));
rgbim(:,:,2) = imadjust(rescale(ddata(:,:,vbands(2)),1));
rgbim(:,:,3) = imadjust(rescale(ddata(:,:,vbands(3)),1));
axes(ha(6)); imshow(rgbim); % display RGB image
set(gca,'xtick',[]), set(gca,'xticklabel',[]), set(gca,'ytick',[]), set(gca,'yticklabel',[])
ddata = Z_hysure;
rgbim(:,:,1) = imadjust(rescale(ddata(:,:,vbands(1)),1));
rgbim(:,:,2) = imadjust(rescale(ddata(:,:,vbands(2)),1));
rgbim(:,:,3) = imadjust(rescale(ddata(:,:,vbands(3)),1));
axes(ha(7)); imshow(rgbim); % display RGB image
set(gca,'xtick',[]), set(gca,'xticklabel',[]), set(gca,'ytick',[]), set(gca,'yticklabel',[])
ddata = Z_glphs;
rgbim(:,:,1) = imadjust(rescale(ddata(:,:,vbands(1)),1));
rgbim(:,:,2) = imadjust(rescale(ddata(:,:,vbands(2)),1));
rgbim(:,:,3) = imadjust(rescale(ddata(:,:,vbands(3)),1));
axes(ha(8)); imshow(rgbim); % display RGB image
set(gca,'xtick',[]), set(gca,'xticklabel',[]), set(gca,'ytick',[]), set(gca,'yticklabel',[])
ddata = Z_cnmf;
rgbim(:,:,1) = imadjust(rescale(ddata(:,:,vbands(1)),1));
rgbim(:,:,2) = imadjust(rescale(ddata(:,:,vbands(2)),1));
rgbim(:,:,3) = imadjust(rescale(ddata(:,:,vbands(3)),1));
axes(ha(9)); imshow(rgbim); % display RGB image
set(gca,'xtick',[]), set(gca,'xticklabel',[]), set(gca,'ytick',[]), set(gca,'yticklabel',[])
ddata = Zh_srr;
rgbim(:,:,1) = imadjust(rescale(ddata(:,:,vbands(1)),1));
rgbim(:,:,2) = imadjust(rescale(ddata(:,:,vbands(2)),1));
rgbim(:,:,3) = imadjust(rescale(ddata(:,:,vbands(3)),1));
axes(ha(10)); imshow(rgbim); % display RGB image
set(gca,'xtick',[]), set(gca,'xticklabel',[]), set(gca,'ytick',[]), set(gca,'yticklabel',[])
axes(ha(1)); ylabel('Visible','interpreter','latex')
axes(ha(6)); ylabel('Infrared','interpreter','latex')
% print(['examples/recIm_ex3b_Playa_vis_IR'],'-dpdf')
% ---------------------------------
% repeat in a single figure
figure; clear rgbim
[ha, pos] = tight_subplot(2, 5, [0.01 0.01], 0.18, 0.1);
% vbands = [57,30,20]; % RGB bands
vbands = [32 20 8]; % RGB bands --> visible spectra OK!
ddata = Zh_th;
rgbim(:,:,1) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(1)),-1)),1));
rgbim(:,:,2) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(2)),-1)),1));
rgbim(:,:,3) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(3)),-1)),1));
axes(ha(1)); imshow(rgbim); % display RGB image
set(gca,'xtick',[]), set(gca,'xticklabel',[]), set(gca,'ytick',[]), set(gca,'yticklabel',[])
title('Reference','interpreter','latex')
ddata = Z_hysure;
rgbim(:,:,1) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(1)),-1)),1));
rgbim(:,:,2) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(2)),-1)),1));
rgbim(:,:,3) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(3)),-1)),1));
axes(ha(2)); imshow(rgbim); % display RGB image
set(gca,'xtick',[]), set(gca,'xticklabel',[]), set(gca,'ytick',[]), set(gca,'yticklabel',[])
title('HySure','interpreter','latex')
ddata = Z_glphs;
rgbim(:,:,1) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(1)),-1)),1));
rgbim(:,:,2) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(2)),-1)),1));
rgbim(:,:,3) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(3)),-1)),1));
axes(ha(3)); imshow(rgbim); % display RGB image
set(gca,'xtick',[]), set(gca,'xticklabel',[]), set(gca,'ytick',[]), set(gca,'yticklabel',[])
title('GLP-HS','interpreter','latex')
ddata = Z_cnmf;
rgbim(:,:,1) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(1)),-1)),1));
rgbim(:,:,2) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(2)),-1)),1));
rgbim(:,:,3) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(3)),-1)),1));
axes(ha(4)); imshow(rgbim); % display RGB image
set(gca,'xtick',[]), set(gca,'xticklabel',[]), set(gca,'ytick',[]), set(gca,'yticklabel',[])
title('CNMF','interpreter','latex')
ddata = Zh_srr;
rgbim(:,:,1) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(1)),-1)),1));
rgbim(:,:,2) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(2)),-1)),1));
rgbim(:,:,3) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(3)),-1)),1));
axes(ha(5)); imshow(rgbim); % display RGB image
set(gca,'xtick',[]), set(gca,'xticklabel',[]), set(gca,'ytick',[]), set(gca,'yticklabel',[])
title('FuVar','interpreter','latex')
% vbands = [57,30,20]; % RGB bands
vbands = [146 108 46]; % RGB bands --> IR OK!
ddata = Zh_th;
rgbim(:,:,1) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(1)),-1)),1));
rgbim(:,:,2) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(2)),-1)),1));
rgbim(:,:,3) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(3)),-1)),1));
axes(ha(6)); imshow(rgbim); % display RGB image
set(gca,'xtick',[]), set(gca,'xticklabel',[]), set(gca,'ytick',[]), set(gca,'yticklabel',[])
ddata = Z_hysure;
rgbim(:,:,1) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(1)),-1)),1));
rgbim(:,:,2) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(2)),-1)),1));
rgbim(:,:,3) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(3)),-1)),1));
axes(ha(7)); imshow(rgbim); % display RGB image
set(gca,'xtick',[]), set(gca,'xticklabel',[]), set(gca,'ytick',[]), set(gca,'yticklabel',[])
ddata = Z_glphs;
rgbim(:,:,1) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(1)),-1)),1));
rgbim(:,:,2) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(2)),-1)),1));
rgbim(:,:,3) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(3)),-1)),1));
axes(ha(8)); imshow(rgbim); % display RGB image
set(gca,'xtick',[]), set(gca,'xticklabel',[]), set(gca,'ytick',[]), set(gca,'yticklabel',[])
ddata = Z_cnmf;
rgbim(:,:,1) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(1)),-1)),1));
rgbim(:,:,2) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(2)),-1)),1));
rgbim(:,:,3) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(3)),-1)),1));
axes(ha(9)); imshow(rgbim); % display RGB image
set(gca,'xtick',[]), set(gca,'xticklabel',[]), set(gca,'ytick',[]), set(gca,'yticklabel',[])
ddata = Zh_srr;
rgbim(:,:,1) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(1)),-1)),1));
rgbim(:,:,2) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(2)),-1)),1));
rgbim(:,:,3) = imadjust(rescale(fliplr(rot90(ddata(:,:,vbands(3)),-1)),1));
axes(ha(10)); imshow(rgbim); % display RGB image
set(gca,'xtick',[]), set(gca,'xticklabel',[]), set(gca,'ytick',[]), set(gca,'yticklabel',[])
axes(ha(1)); ylabel('Visible','interpreter','latex')
axes(ha(6)); ylabel('Infrared','interpreter','latex')
% print(['examples/recIm_ex3b_Playa_vis_IR2'],'-dpdf')
figure;
plot(qualIdx_hysure.psnrall)
hold on
plot(qualIdx_glphs.psnrall)
plot(qualIdx_cnmf.psnrall)
plot(qualIdx_srr.psnrall)
xlim([1 length(qualIdx_hysure.psnrall)])
legend('HySure','GLP-HS','CNMF','FuVar')
xlabel('Spectral band')
ylabel('PSNR [dB]')
% print(['examples/PSNR_band_ex3b_Playa'],'-dpdf')
figure;
[ha, pos] = tight_subplot(1, 4, 0.01, 0.1, [0.1 0.15]);
mmax = max([max(qualIdx_hysure.sammap(:)) max(qualIdx_glphs.sammap(:)) ...
max(qualIdx_cnmf.sammap(:)) max(qualIdx_srr.sammap(:))]);
mmin = min([min(qualIdx_hysure.sammap(:)) min(qualIdx_glphs.sammap(:)) ...
min(qualIdx_cnmf.sammap(:)) min(qualIdx_srr.sammap(:))]);
axes(ha(1)); imagesc(qualIdx_hysure.sammap, [mmin mmax])
title('HySure','interpreter','latex'), set(gca,'ytick',[],'xtick',[]), axis square
axes(ha(2)); imagesc(qualIdx_glphs.sammap, [mmin mmax])
title('GLP-HS','interpreter','latex'), set(gca,'ytick',[],'xtick',[]), axis square
axes(ha(3)); imagesc(qualIdx_cnmf.sammap, [mmin mmax])
title('CNMF','interpreter','latex'), set(gca,'ytick',[],'xtick',[]), axis square
axes(ha(4)); imagesc(qualIdx_srr.sammap, [mmin mmax])
title('FuVar','interpreter','latex'), set(gca,'ytick',[],'xtick',[]), axis square
originalSize2 = get(gca, 'Position');
h=colorbar;
set(ha(4), 'Position', originalSize2);
set(h,'fontsize',12);
% print(['examples/SAM_map_ex3b_Playa'],'-dpdf')
%%