-
Notifications
You must be signed in to change notification settings - Fork 58
/
Fmask_4_6.m
109 lines (101 loc) · 4.23 KB
/
Fmask_4_6.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
function Fmask_4_6(input1, input2, input3, input4, input5)
%% Standalone of Fmask 4.6 version
% Input formats
%
% 1) Set default program
% Fmask_4_6()
%
% 2) Set buffers of cloud, shadow, and snow/ice
% Fmask_4_6(3, 3, 1)
%
% 3) Set buffers of cloud, shadow, and snow/ice, and thershold of cloud probability
% Fmask_4_6(3, 3, 3, 22.5)
%
%
% Below cases are to setup the directory of the auxiliary data (the folder
% <AuxiData>) for the implement which fails to locate the directory by the
% default settings. To examine this, please process a image using the
% default program (like case 1), and if a warning message 'Fail to locate
% the directory of auxiliary data' presents, this means the default
% settings do not work, and then you need to custumize the directory of
% auxiliary data using below inputs.
%
% This problem usually occurs in Linux system.
% (a warning message 'Fail to locate the directory of auxiliary data' will presents).
%
% Note: Start up from the Matlab code will not be afffected, and please
% ignore the below cases
%
% Please consider them only when a warning message 'Fail to locate the auxiliary data' presents at default model
%
% 4) Set the directory of the auxiliary data
% Fmask_4_6('C:\Users\xxx\xxx\Fmask_4_4\AuxiData')
%
% 5) Set buffers of cloud, shadow, and snow/ice, and the auxiliary data
% Fmask_4_6(3, 3, 0, 'C:\Users\xxx\xxx\Fmask_4_4\AuxiData')
%
% 6) Set buffers of cloud, shadow, and snow/ice, thershold of cloud probability, and the auxiliary data
% Fmask_4_6(3, 3, 0, 22.5, 'C:\Users\xxx\xxx\Fmask_4_4\AuxiData')
%
%% Case 1)
if ~exist('input1', 'var')
autoFmask(); % default buffering pixels for cloud, cloud shadow, and snow
return;
end
%% Case 2)
if exist('input3', 'var')&& ~exist('input4', 'var')
autoFmask('cloud', force2num(input1),'shadow', force2num(input2), 'snow', force2num(input3));
return;
end
if exist('input4', 'var')&& ~exist('input5', 'var')
if isnumeric(input4) || ~isfolder(input4)
%% Case 3)
autoFmask('cloud', force2num(input1),'shadow', force2num(input2), 'snow', force2num(input3), 'p', force2num(input4));
else
%% Case 5)
if isfolder(fullfile(input4, 'GTOPO30ZIP')) && isfolder(fullfile(input4, 'GSWO150ZIP'))
autoFmask('cloud', force2num(input1),'shadow', force2num(input2), 'snow', force2num(input3), 'auxi', input4);
else
fprintf('Do not find the directory of the auxiliary data. Please input a correct one. \r');
end
end
return;
end
%% Case 4)
if exist('input1', 'var') && ~exist('input2', 'var')
if isfolder(input1) && isfolder(fullfile(input1, 'GTOPO30ZIP')) && isfolder(fullfile(input1, 'GSWO150ZIP'))
autoFmask('auxi', input1);
else
fprintf('Do not find the directory of the auxiliary data. Please correct it. \r');
end
return;
end
%% Case 6)
if exist('input5', 'var')
% cldpix =input1; sdpix = input2; snpix = input3; cldprob = input4; pathauxi = input5;
if isfolder(input5) && isfolder(fullfile(input5, 'GTOPO30ZIP')) && isfolder(fullfile(input5, 'GSWO150ZIP'))
autoFmask('cloud',force2num(input1),'shadow',force2num(input2),'snow',force2num(input3),'p',force2num(input4), 'auxi', input5);
else
fprintf('Do not find the directory of the auxiliary data. Please correct it. \r');
end
return;
end
end
function input2 = force2num(input2)
%% convert to number input if not
if ~isnumeric(input2)
input2 = str2num(input2);
end
end
% old version
%
% if exist('cldpix','var')==1&&exist('sdpix','var')==1&&exist('snpix','var')==1
% if exist('cldprob','var')==1
% autoFmask('cloud',str2num(cldpix),'shadow',str2num(sdpix),'snow',str2num(snpix),'p',str2num(cldprob));
% else
% autoFmask('cloud',str2num(cldpix),'shadow',str2num(sdpix),'snow',str2num(snpix));
% end
% else
% % default buffering pixels for cloud, cloud shadow, and snow
% autoFmask();
% end