-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathreadDataset.m
executable file
·51 lines (45 loc) · 1.51 KB
/
readDataset.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
%% dataset
if strcmp(dataset, 'after-rain')==true
rawFileType = 'tif';
labelFileTpype = 'png';
datasetRoute = [route, 'After-Rain/'];
elseif strcmp(dataset, 'sunny-shadows')==true
rawFileType = 'tif';
labelFileTpype = 'png';
datasetRoute = [route, 'Sunny-Shadows/'];
elseif strcmp(dataset, 'kitti_layout')==true
rawFileType = 'png';
labelFileTpype = 'tif';
datasetRoute = [route, 'KITTI_Layout/'];
end
%% read images and labels
files = dir( [datasetRoute, '*.', labelFileTpype] );
fileNum = length(files);
imCell = cell(fileNum,1);
labCell = cell(fileNum,1);
for i = 1:fileNum
name = files(i).name;
lab = imread([datasetRoute, name]);
if strcmp(dataset,'sunny-shadows')==true
name = name(1:end-1);
name(end-2:end) = rawFileType;
else
name(end-2:end) = rawFileType;
end
im = imread([datasetRoute, name]);
dim = size(im);
if strcmp(dataset,'groundtruth')==true
labCell{i} = logical(1-imresize(rgb2gray(lab), ns));
% imCell{i} = imresize(im2double(im), ns);
imCell{i} = imresize(im, ns);
elseif (strcmp(dataset,'kitti_semantic')==true || ...
strcmp(dataset,'kitti_layout')==true) && ...
ns(2)==160
labCell{i} = logical(tailorWide2Normal(lab,ns));
imCell{i} = tailorWide2Normal(im2double(im),ns);
else
labCell{i} = logical(imresize(lab, ns));
% imCell{i} = imresize(im2double(im), ns);
imCell{i} = imresize(im, ns);
end
end