[06669b]: / resizeCEPixelLabels.m

Download this file

32 lines (26 with data), 835 Bytes

 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
% Developer: Tonmoy Ghosh (tghosh@crimson.ua.edu)
function pxds = resizeCEPixelLabels(pxds, labelFolder)
% Resize pixel label data to [360 480].
classes = pxds.ClassNames;
labelIDs = 1:numel(classes);
if ~exist(labelFolder,'dir')
mkdir(labelFolder)
%else
%pxds = pixelLabelDatastore(labelFolder,classes,labelIDs);
%return; % Skip if images already resized
end
reset(pxds)
while hasdata(pxds)
% Read the pixel data.
[C,info] = read(pxds);
% Convert from categorical to uint8.
L = uint8(C{1});
% Resize the data. Use 'nearest' interpolation to
% preserve label IDs.
L = imresize(L,[256 256],'nearest');
% Write the data to disk.
[~, filename, ext] = fileparts(info.Filename);
imwrite(L,[labelFolder filename ext])
end
pxds = pixelLabelDatastore(labelFolder,classes,labelIDs);
end