-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.m
More file actions
144 lines (122 loc) · 4.96 KB
/
Copy pathMain.m
File metadata and controls
144 lines (122 loc) · 4.96 KB
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
%% Polarimetric-Naive Bayes Flood mapping approach
% DATE OF CREATION OF DOCUMENT: 16/09/2021
% AUTHOR: SAMVEDYA SURAMPUDI @Microwave lab, VIT University %%
%%
clc
clear all
%_________________________SECTION-I_______________________________________
% (Reading data and initializing sizes)
[lulc, flood, pol]=read_input();
tic
h=waitbar(0.1,'Please wait while model is running.................');
pause(1)
delete(h)
% Initializing sizes
sz1_fld=size(flood,1);
sz2_fld=size(flood,2);
%[l1,l2,l3]=Lc2msk(lulc,4);
% Edit data in the below variables that accurately represents individual features on LULC map
% Each 'l' has only four data cells
% Example O Figure1 - l1{1,1}
% O Figure7 - l2{1,3}
% O Figure10 - l3{1,2}
% hyd=l3{1,2}; % Water
% bul=l2{1,3}; % Buildings
% veg=l3{1,1}; % Vegetation
% wetl=l3{1,4}; % wetlands
% road=l2{1,4}; % Roads
% ot=zeros(sz1_fld,sz2_fld);
% ot(find(hyd==0&bul==0&veg==0&wetl==0&road==0))=1; % Others
h=waitbar(0.5,'Please wait while model is running.................');
pause(0.5)
delete(h)
% Mergeing class labels in polarimetric dataset based on LULC
h=waitbar(0.7,'Please wait while model is running.................');
pause(0.5)
delete(h)
%**********************************************
nclas_data=max(pol(:));
No_cls=select_cls(nclas_data);
[pol_new,lab_new]=merge_cls(pol,16,No_cls);
pol1=pol_new;
%************************************************
% \\\\ Buildings, Vegetation, Roads classes are unchanged ?? \\\\
% Fix class labels for buildings, vegetation and roads?
% pol1(find(bul==1))=lab_new(end)+1;
% pol1(find(veg==1))=lab_new(end)+2;
% pol1(find(road==1))=lab_new(end)+3;
% pol1(find(ot==1))=lab_new(end)+4;
% figure(1)
% imshow(pol1,[]); colormap (rand(16,3)); impixelinfo;
% Labelling the data
table(:,1)=flood(:);
table(:,2)=pol1(:);
F_vec=flood(:);
% Flood vector
%[fin_map,scores,c_lab]=GMM(table,F_vec ,nclas,flood,pol)
% nclass should be same as in merge_cls. Refer GMM function for more information
[fin_map,scores,c_lab,c_lab_new]=GMM(table,F_vec,No_cls,flood,pol1);
cmap=rand(16,3);
imwrite(fin_map,cmap,'classified.bmp')
%%
% Accuracy assessment
figure(2);
CM=confusionchart(double(table(:,2)),fin_map(:),'RowSummary','row-normalized','ColumnSummary','column-normalized');
CM=confusionchart(c_lab,c_lab_new,'RowSummary','row-normalized','ColumnSummary','column-normalized');
accuracy = sum(table(:,2) == fin_map(:),'all')/numel(fin_map(:))*100;
time=toc;
% msgbox(sprintf("Accuracy= %d",accuracy),'METRICS')
% Receiver Operating Characteristics
% While calculating AUC- labels(nclas)is <= nclas value in GMM and
% merge_cls
% [X,Y,T,AUC] = perfcurve(c_lab_new(1:1000),scores(1:1000),labels(1));
% plot(X,Y); xlabel('False positive rate'); ylabel('True positive rate')
% hold on;
% [X,Y,T,AUC] = perfcurve(c_lab_new(1:1000),scores(1:1000),labels(2));
% plot(X,Y); xlabel('False positive rate'); ylabel('True positive rate')
% hold on;
% [X,Y,T,AUC] = perfcurve(c_lab_new(1:1000),scores(1:1000),labels(3));
% plot(X,Y); xlabel('False positive rate'); ylabel('True positive rate')
% hold on;
% [X,Y,T,AUC] = perfcurve(c_lab_new(1:1000),scores(1:1000),labels(4));
% plot(X,Y); xlabel('False positive rate'); ylabel('True positive rate')
% hold on;
% [X,Y,T,AUC] = perfcurve(c_lab_new(1:1000),scores(1:1000),labels(5));
% plot(X,Y); xlabel('False positive rate'); ylabel('True positive rate')
% hold on;
% [X,Y,T,AUC] = perfcurve(c_lab_new(1:1000),scores(1:1000),labels(6));
% plot(X,Y); xlabel('False positive rate'); ylabel('True positive rate')
% hold on;
% plot(X,Y); xlabel('False positive rate'); ylabel('True positive rate')
% hold on;
% [X,Y,T,AUC] = perfcurve(c_lab_new(1:1000),scores(1:1000),labels(10));
% plot(X,Y); xlabel('False positive rate'); ylabel('True positive rate')
% hold on;
% [X,Y,T,AUC] = perfcurve(c_lab(1:1000),scores(1:1000),labels(11));
% plot(X,Y); xlabel('False positive rate'); ylabel('True positive rate')
% Ive to assign names to new class labels and then compare the
% model. Test here and change in GMM
% Test all the models with different n_class
% the zero class is coming because of unclassified pixels.
% Read the naive bayes docmumentation again and adjust >nmean
%%
% cmap1=rand(16,3);
% cmap2=rand(16,3);
% figure(9);imshow(mm2,[]);colormap(cmap2);impixelinfo;
% figure(5);imagesc(flood);colormap('Gray');impixelinfo;
% figure(9);imagesc(mm2);colormap(cmap2);%impixelinfo;
%
% ylim = get(gca, 'ylim');
% Ylt = [400,800];
% set(gca, 'YLim', Ylt)
% pause
% Ylb = [400,800];
% set(gca, 'YLim', Ylb)
% pause
% xlim = get(gca, 'xlim');
% xlt = [400,800];
% set(gca, 'XLim', xlt)
% pause
% xlb = [400,800];
% set(gca, 'XLim', xlb)
% pause