function hyperDemo2
% HYPERDEMO2 Demonstrates new functions in the hyperspectral toolbox
clear all; close all; clc;
%--------------------------------------------------------------------------
% Measurements and reflectance (input) files/directory
% The data files are obtained from: http://aviris.jpl.nasa.gov/data/free_data.html
% (the reflectance .rar file for Cuprite)
dataDir = ['~' filesep 'Downloads' filesep 'f970619t01p02r02c'];
rflFile = [dataDir filesep 'f970619t01p02_r02_sc04.a.rfl'];
spcFile = [dataDir filesep 'f970619t01p02_r02.a.spc'];
% Results (output) directory
resultsDir = '~/Dropbox/Purdue Grad/Semester 2/AAE 590/Project/Simulation/results';
if ~isdir(resultsDir)
mkdir(resultsDir);
end
%--------------------------------------------------------------------------
% Record outputs (not including figures)
diary(sprintf('%s/log.txt',resultsDir))
dnt = fix(clock); % date and time
fprintf('%d/%d/%d %d:%d:%d\n\n', dnt([2,3,1,4,5,6]))
fprintf(' Reading data from %s \n in the directory %s.\n', rflFile, dataDir);
fprintf(' Storing results in %s directory.\n', resultsDir);
%% Read in an HSI image and display one band
bndnum = 120; % Band Number
tmp = hyperReadAvirisSpc(spcFile);
bnd = tmp(bndnum);
slice = hyperReadAvirisRfl(rflFile, [1 512], [1 614], [bndnum bndnum]);
figure; imagesc(slice); axis image; colormap(gray);
title(['Slice of HSI, at $\lambda=$',sprintf('%5.6g nm',bnd)],...
'Interpreter', 'Latex', 'FontSize', 14);
print(gcf, '-r600', '-depsc', sprintf('%s/sampleSlice', resultsDir));
%% True Color Composite
rgbBands = [31,20,12]; % RGB bands (default): [665.73, 557.07, 478.17] nm
tColor = hyperTruecolor(rflFile, 512, 614, 224, rgbBands, 'stretchlim');
figure; imagesc(tColor); axis image
title('Cuprite, Nevada. AVIRIS 1997 data.', 'Interpreter', 'Latex', 'FontSize', 14);
print(gcf, '-r600', '-depsc', sprintf('%s/truecolor', resultsDir));
%% Read part of AVIRIS reflectance data file that we will further process
M = hyperReadAvirisRfl(rflFile, [1 512], [1 614], [1 224]);
% Read AVIRIS .spc file
lambdasNm = hyperReadAvirisSpc(spcFile);
% Resample AVIRIS image
[h, w, p] = size(M);
M2d = hyperConvert2d(M);
desiredLambdasNm = 400:(2400-400)/(224-1):2400;
fprintf('Resampling M for desired wavelengths...\n'); tic;
M2d = hyperResample(M2d, lambdasNm, desiredLambdasNm);
et=toc; fprintf('...Done. (~%1.3g seconds)\n',et);
%% Remove low SNR bands and bands affected by water absorption
% Examine the spectral profile of some random pixels (targets)
M = hyperConvert3d(M2d, h, w, p);
ntarg = 20; % number of targets
htarg = randi(h, 1, ntarg); % h position of targets
wtarg = randi(w, 1, ntarg); % w position of targets
targets = zeros(ntarg, p);
for idx = 1:ntarg
targets(idx,:) = squeeze(M(htarg(idx), wtarg(idx), :));
end
figure;
set(0,'Units','pixels'); scnsz = get(0,'ScreenSize');
set(gcf, 'OuterPosition',[1,1,scnsz(3)/3,scnsz(4)],'PaperPositionMode', 'auto');
subplot(211);
plot(desiredLambdasNm, targets, '.'); grid on; ylim([0,0.6]);
title(sprintf('(a) %d Target Signatures (All Bands)', ntarg), 'Interpreter', 'Latex', 'FontSize', 14);
ax(1) = xlabel('Wavelengths [nm]');
ax(2) = ylabel('Reflectance');
set(ax, 'Interpreter', 'Latex', 'FontSize', 12);
fprintf('Removing low SNR bands...\n');
% [rows,cols,vals]=find(sum(M2d,2)==0);
% goodBands = [4:104 116:149 171:224];
goodBands = [4:104 116:135 137:149 174:224];
M2d = M2d(goodBands, :);
p = length(goodBands);
lambdasNm = desiredLambdasNm(goodBands);
% Final hyperspectral data cube that will be used throughout this demo
M = hyperConvert3d(M2d, h, w, p);
fprintf('...Done\n');
% Plot new target signatures (only good bands now)
targets = zeros(ntarg, p);
for idx = 1:ntarg
targets(idx,:) = squeeze(M(htarg(idx), wtarg(idx), :));
end
subplot(212); plot(lambdasNm, targets, '.'); grid on; ylim([0,0.6]);
title(sprintf('(b) %d Target Signatures (Good Bands)', ntarg), 'Interpreter', 'Latex', 'FontSize', 14);
ax(1) = xlabel('Wavelengths [nm]');
ax(2) = ylabel('Reflectance');
set(ax, 'Interpreter', 'Latex', 'FontSize', 12);
print(gcf, '-r600', '-depsc', sprintf('%s/targets_spectra', resultsDir));
%% --------------------------------------------------------------------------
% Perform various endmember determination algorithms
% Estimate number of endmembers in image.
% q = hyperHfcVd(M2d, [10^-3]); % doesn't work because corr(M') returns
% some NaNs, which means that there's no variance in some of the bands...
q = 6; % number of endmembers to find
% M2dnorm = hyperNormalize(M2d); % normalized [0-1] reflectance
%% PPI
fprintf('Performing PPI for endmember determination...\n'); tic;
Uppi = hyperPpi(M2d, q, 1000);
et=toc; fprintf('...Done. (~%1.3g seconds)\n',et);
% Plot endmember signatures
figure; plot(lambdasNm, Uppi, '.'); grid on;
title('PPI Recovered Endmembers', 'Interpreter', 'Latex', 'FontSize', 14);
ax(1) = ylabel('Reflectance [0-1]');
ax(2) = xlabel('Wavelength [nm]');
set(ax, 'Interpreter', 'Latex', 'FontSize', 12);
l = legend(cellstr(num2str((1:q)'))', 'Location', 'EastOutside');
a = get(l, 'children'); set(a(1:3:end), 'MarkerSize', 20);
print(gcf, '-r600', '-depsc', sprintf('%s/endmmbrs-ppi', resultsDir));
%% N-FINDR
fprintf('Performing N-FINDR for endmember determination...\n'); tic;
Unfindr = hyperNfindr(M2d, q);
et=toc; fprintf('...Done. (~%1.3g seconds)\n',et);
% Plot endmember signatures
figure; plot(lambdasNm, Unfindr, '.'); grid on;
title('N-FINDR Recovered Endmembers', 'Interpreter', 'Latex', 'FontSize', 14);
ax(1) = ylabel('Reflectance [0-1]');
ax(2) = xlabel('Wavelength [nm]');
set(ax, 'Interpreter', 'Latex', 'FontSize', 12);
l = legend(cellstr(num2str((1:q)'))', 'Location', 'EastOutside');
a = get(l, 'children'); set(a(1:3:end), 'MarkerSize', 20);
print(gcf, '-r600', '-depsc', sprintf('%s/endmmbrs-nfindr', resultsDir));
%% AVMAX
fprintf('Performing AVMAX for endmember determination...\n'); tic;
Uavmax = hyperAvmax(M2d, q);
et=toc; fprintf('...Done. (~%1.3g seconds)\n',et);
% Plot endmember signatures
figure; plot(lambdasNm, Uavmax, '.'); grid on;
title('AVMAX Recovered Endmembers', 'Interpreter', 'Latex', 'FontSize', 14);
ax(1) = ylabel('Reflectance [0-1]');
ax(2) = xlabel('Wavelength [nm]');
set(ax, 'Interpreter', 'Latex', 'FontSize', 12);
l = legend(cellstr(num2str((1:q)'))', 'Location', 'EastOutside');
a = get(l, 'children'); set(a(1:3:end), 'MarkerSize', 20);
print(gcf, '-r600', '-depsc', sprintf('%s/endmmbrs-avmax', resultsDir));
%% AMEE
fprintf('Performing AMEE for endmember determination...\n'); tic;
Uamee = hyperAmee(M, q, 5);
et=toc; fprintf('...Done. (~%1.3g seconds)\n',et);
% Plot endmember signatures
figure; plot(lambdasNm, Uamee, '.'); grid on; ylim([0,1]);
title('AMEE Recovered Endmembers', 'Interpreter', 'Latex', 'FontSize', 14);
ax(1) = ylabel('Reflectance [0-1]');
ax(2) = xlabel('Wavelength [nm]');
set(ax, 'Interpreter', 'Latex', 'FontSize', 12);
l = legend(cellstr(num2str((1:q)'))', 'Location', 'EastOutside');
a = get(l, 'children'); set(a(1:3:end), 'MarkerSize', 20);
print(gcf, '-r600', '-depsc', sprintf('%s/endmmbrs-amee', resultsDir));
%% --------------------------------------------------------------------------
% Create abundance maps from unmixed endmembers
%% From PPI results:
fprintf('Creating abundance maps from PPI endmember results...\n'); tic;
abundanceMaps = hyperNnls(M2d, Uppi);
abundanceMaps = hyperConvert3d(abundanceMaps, h, w, q);
et=toc; fprintf('...Done. (~%1.3g seconds)\n',et);
fprintf('Plotting and saving PPI abundance maps...\n');
for i=1:q
if i==1; figure; end;
clf; imagesc(abundanceMaps(:,:,i)); colorbar; axis image;
title(sprintf('Abundance Map %d/%d', i, q), 'Interpreter', 'Latex');
print(gcf, '-depsc', '-r600', sprintf('%s/abund-ppi-%d', resultsDir, i))
end
close(gcf); fprintf('...Done.\n');
%% From N-FINDR results:
fprintf('Creating abundance maps from N-FINDR endmember results...\n'); tic;
abundanceMaps = h
没有合适的资源?快使用搜索试试~ 我知道了~
常用的高光谱算法matlab.zip
共66个文件
m:66个
需积分: 50 136 下载量 109 浏览量
2020-06-20
10:26:46
上传
评论 27
收藏 60KB ZIP 举报
温馨提示
常用的高光谱混合像元分解算法,包括降维(VCA、MNF)、端元估计(GLRT)、端元提取(nFINER、PPI、AMEE等)、丰度反演(FCL、UCLS等)、探测(HUD、OSP、CEM等)
资源推荐
资源详情
资源评论
收起资源包目录
常用的高光谱算法matlab.zip (66个子文件)
常用的高光谱混合像元分解算法
hyperNormalize.m 446B
hyperTruecolor.m 2KB
fnnls.m 4KB
hyperSaveFigure.m 796B
hypeVar.m 233B
hyperWhiten.m 971B
hyperPlmf.m 2KB
hyperIcaComponentScores.m 923B
hyperNapc.m 2KB
hyperSid.m 641B
hyperIcaEea.m 2KB
hyperRxDetector.m 633B
hyperOrthorectify.m 966B
hyperResample.m 1KB
hyperCem.m 1KB
hyperAvgE.m 718B
hyperMatchedFilter.m 1KB
hyperFcls.m 2KB
hyperMnf.m 1KB
hyperGlrt.m 802B
hyperDemo2.m 10KB
freadenvi.m 3KB
hyperFileFind.m 1KB
hyperAmee.m 4KB
hyperGetEnviSignature.m 718B
hyperReadSpecpr.m 5KB
hyperGetHymapWavelengthsNm.m 2KB
hyperRnfindr.m 785B
hyperConvert3d.m 510B
hyperHfcVd.m 2KB
hyperConvert2d.m 521B
hyperCov.m 379B
hyperAtgp.m 1KB
hyperImagesc.m 635B
hyperDemo.m 4KB
hyperNormXCorr.m 776B
hyperImshow.m 613B
hyperOsp.m 916B
hyperAmsd.m 887B
hyperReadAvirisRfl.m 3KB
hyperRoc.m 177B
hyperDemo_RIT_data.m 7KB
hyperNfindr.m 3KB
hyperDestreak.m 964B
hyperConvert2Colormap.m 856B
hyperDemo_detectors.m 4KB
hyperSignedAce.m 944B
hyperVca.m 3KB
hyperAce.m 1KB
hyperHud.m 2KB
hyperNnls.m 1KB
hyperConvexHullRemoval.m 1KB
FCLSU.m 1KB
hyperMax2d.m 371B
hyperCorr.m 316B
hyperAvmax.m 3KB
hyperDemo_ASD_reader.m 1KB
hyperPpi.m 838B
hyperReadAvirisSpc.m 615B
hyperUcls.m 649B
hyperSam.m 2KB
hyperDemo_mams_RIT_data.m 3KB
hyperFclsMatlab.m 978B
hyperRmf.m 2KB
hyperReadAsd.m 4KB
hyperPct.m 772B
共 66 条
- 1
资源评论
菠萝大仙
- 粉丝: 7
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功