Diff of /resizeCEPixelLabels.m [000000] .. [06669b]

Switch to unified view

a b/resizeCEPixelLabels.m
1
% Developer: Tonmoy Ghosh (tghosh@crimson.ua.edu)
2
function pxds = resizeCEPixelLabels(pxds, labelFolder)
3
% Resize pixel label data to [360 480].
4
5
classes = pxds.ClassNames;
6
labelIDs = 1:numel(classes);
7
if ~exist(labelFolder,'dir')
8
    mkdir(labelFolder)
9
%else
10
    %pxds = pixelLabelDatastore(labelFolder,classes,labelIDs);
11
    %return; % Skip if images already resized
12
end
13
14
reset(pxds)
15
while hasdata(pxds)
16
    % Read the pixel data.
17
    [C,info] = read(pxds);
18
19
    % Convert from categorical to uint8.
20
    L = uint8(C{1});
21
22
    % Resize the data. Use 'nearest' interpolation to
23
    % preserve label IDs.
24
    L = imresize(L,[256 256],'nearest');
25
26
    % Write the data to disk.
27
    [~, filename, ext] = fileparts(info.Filename);
28
    imwrite(L,[labelFolder filename ext])
29
end
30
31
pxds = pixelLabelDatastore(labelFolder,classes,labelIDs);
32
end