-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKeyPeriodImages2Gis.m
99 lines (80 loc) · 4.03 KB
/
KeyPeriodImages2Gis.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
%% Export extracted waters edge to shapefile for start and end of key periods
%
% Reads in data from 'outputs\PhotoDatabase.mat' and
% 'outputs\ShortlistPhotos.mat' which have been generated by the
% ImageAnalysis script.
%
% This script relies on the imageAnalysis2GIS function.
%
% See also: IMAGEANALYSIS, IMAGEANALYSIS2GIS.
%% Setup
% Add required directories (and subdirectories)
addpath(genpath('functions'))
addpath(genpath('inputs'))
% Read input parameters
Config = HurunuiAnalysisConfig;
%% Load data
% Read image data (processed by ImageAnalysis)
load('outputs\PhotoDatabase.mat');
load('outputs\ShortlistPhotos.mat')
%% Export start and end of key periods
Alphabet = num2cell('ABCDEFGHIJKLMNOPQRSTUVWXYZ');
PhotoDay = dateshift(ShortlistPhotos.UniqueTime,'start','day');
for PeriodNo = 1:size(Config.KeyPeriods,1)
fprintf('Outputing gis data for period %s\n', Alphabet{PeriodNo})
OutputFolder = fullfile('outputs', sprintf('Period%s', Alphabet{PeriodNo}));
if ~exist(OutputFolder,'dir')
mkdir(OutputFolder);
end
StartEndLabel = {'Start','End'};
for StartEnd = 1:2
% Select the next quality photo after the date of interest
PhotoNo = find(PhotoDay == Config.KeyPeriods(PeriodNo,StartEnd) & ...
ShortlistPhotos.WetBdyOK, 1);
% Generate the filename
FileName = sprintf('Period%s_%s_%s', Alphabet{PeriodNo}, ...
StartEndLabel{StartEnd}, ...
datestr(ShortlistPhotos.UniqueTime(PhotoNo),'yyyy-mm-dd_HH-MM-SS'));
FileName = fullfile(OutputFolder, FileName);
% Generate the required inputs for imageAnalysis2GIS
Cam1No = ShortlistPhotos.Cam1Photo(PhotoNo);
Cam1Image = imread(fullfile(Config.DataFolder, Config.PhotoFolder, ...
Photos.FileSubDir{Cam1No}, [Photos.FileName{Cam1No}, '.jpg']));
Cam2No = ShortlistPhotos.Cam2Photo(PhotoNo);
Cam2Image = imread(fullfile(Config.DataFolder, Config.PhotoFolder, ...
Photos.FileSubDir{Cam2No}, [Photos.FileName{Cam2No}, '.jpg']));
% Output the WetBdy and projected images to GIS
imageAnalysis2GIS(Config, FileName, Cam1Image, Cam2Image, ...
ShortlistPhotos.LagoonLevel(PhotoNo), ...
ShortlistPhotos.Twist(PhotoNo,:), ...
ShortlistPhotos.WetBdy{PhotoNo})
end
end
%% Export other key dates
PhotoDay = dateshift(ShortlistPhotos.UniqueTime,'start','day');
for SnapshotNo = 1:size(Config.SnapshotDates,1)
fprintf('Outputing gis data for snapshot %i\n', SnapshotNo)
OutputFolder = fullfile('outputs', sprintf('Snapshot%2i', SnapshotNo));
if ~exist(OutputFolder,'dir')
mkdir(OutputFolder);
end
% Select the next quality photo after the date of interest
PhotoNo = find(PhotoDay == Config.SnapshotDates(SnapshotNo) & ...
ShortlistPhotos.WetBdyOK, 1);
% Generate the filename
FileName = sprintf('Snapshot%2i_%s', SnapshotNo, ...
datestr(ShortlistPhotos.UniqueTime(PhotoNo),'yyyy-mm-dd_HH-MM-SS'));
FileName = fullfile(OutputFolder, FileName);
% Generate the required inputs for imageAnalysis2GIS
Cam1No = ShortlistPhotos.Cam1Photo(PhotoNo);
Cam1Image = imread(fullfile(Config.DataFolder, Config.PhotoFolder, ...
Photos.FileSubDir{Cam1No}, [Photos.FileName{Cam1No}, '.jpg']));
Cam2No = ShortlistPhotos.Cam2Photo(PhotoNo);
Cam2Image = imread(fullfile(Config.DataFolder, Config.PhotoFolder, ...
Photos.FileSubDir{Cam2No}, [Photos.FileName{Cam2No}, '.jpg']));
% Output the WetBdy and projected images to GIS
imageAnalysis2GIS(Config, FileName, Cam1Image, Cam2Image, ...
ShortlistPhotos.LagoonLevel(PhotoNo), ...
ShortlistPhotos.Twist(PhotoNo,:), ...
ShortlistPhotos.WetBdy{PhotoNo})
end