annotate toolboxes/FullBNT-1.0.7/KPMtools/cell2matPad.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function data2 = cell2matPad(data)
Daniel@0 2 % data{f}(y,x,b) - each frame can have a different size (can can even be empty)
Daniel@0 3 % data2(y,x,b,f) = zero padded version
Daniel@0 4
Daniel@0 5 Nframes = length(data);
Daniel@0 6 Nbands = -inf;
Daniel@0 7 nr = -inf; nc = -inf;
Daniel@0 8 for f=1:Nframes
Daniel@0 9 if isempty(data{f}), continue; end
Daniel@0 10 nr = max(nr, size(data{f},1));
Daniel@0 11 nc = max(nc, size(data{f},2));
Daniel@0 12 Nbands = max(Nbands, size(data{f},3));
Daniel@0 13 end
Daniel@0 14 data2 = zeros(nr, nc, Nbands, Nframes);
Daniel@0 15 for f=1:Nframes
Daniel@0 16 if isempty(data{f}), continue; end
Daniel@0 17 data2(1:size(data{f},1), 1:size(data{f},2), :, f) = data{f};
Daniel@0 18 end
Daniel@0 19 if Nbands == 1
Daniel@0 20 data2 = squeeze(data2); % reshape(data2, [size(data2,1), size(data2,2), Nframes]);
Daniel@0 21 end
Daniel@0 22