-
Notifications
You must be signed in to change notification settings - Fork 13
/
main_detect_syn.m
executable file
·67 lines (58 loc) · 1.66 KB
/
main_detect_syn.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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% anomaly detection
%% Written by Ying Qu
%% Reference
%% Ying Qu, Wei Wang, Rui Guo, Bulent Ayhan, Chiman Kwan, Steven Vance, and Hairong Qi.
%% "Hyperspectral Anomaly Detection through Spectral Unmixing and Dictionary based Low Rank Decomposition",
%% accepted by IEEE Transactions on Geoscience and Remote Sensing (TGRS)
%% All rights reserved
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% clear
addpath(genpath('./meanshift'));
addpath(genpath('./lrr'));
addpath(genpath('./mvcnmf'));
load data/mixed;
load data/sest;
X = mixed;
[M,N,Bands] = size(X);
input = reshape(X,M*N, Bands);
input = input';
numComp = 6;
input = input/max(input(:));
% % spectral unmixing
% tic
% [Aest,sest] = do_nmfdecomp(input,numComp,M,N);
% toc
% clustering
% % % start clustering
tic
bandwidth = 0.1;
[clustCent1,point2cluster1,clustMembsCell1] = HGMeanShiftCluster(sest,bandwidth,'gaussian');
toc
% dictionary construction
dict = [];
for idx = 1:size(clustCent1,2)
a0 = clustCent1(:,idx);
dict = [dict a0];
if size(clustMembsCell1{idx},2) ~=0
merr = [];
for i=1:size(clustMembsCell1{idx},2)
x = clustMembsCell1{idx}(i);
tmp = (sest(:,x)-a0)'*(sest(:,x)-a0);
merr = [merr tmp];
end
[tmp idxsort] = sort(merr);
a2 = sest(:,clustMembsCell1{idx}(idxsort(end)));
end
dict = [dict a2];
end
lambda = 0.15;
%% Dictionary based low-rank decomposition
tic
for k=1:length(lambda)
[A_hat,E_hat] = inexact_alm_lrr_l1(sest,dict,lambda(k),0,0);
anomalylayer(k,:) = sum(E_hat,1)';
anomalyimage(:,:,k) = reshape(anomalylayer(k,:),M,N);
figure, imagesc(anomalyimage(:,:,k));
end
toc