annotate Problems/private/countcover.m @ 68:f2ca04532eac

(none)
author idamnjanovic
date Wed, 16 Mar 2011 14:13:48 +0000
parents 42fcbcfca132
children
rev   line source
idamnjanovic@61 1 function cnt = countcover(sz,blocksize,stepsize)
idamnjanovic@61 2 %COUNTCOVER Covering of signal samples by blocks
idamnjanovic@61 3 % CNT = COUNTCOVER(SZ,BLOCKSIZE,STEPSIZE) assumes a p-dimensional signal
idamnjanovic@61 4 % of size SZ=[N1 N2 ... Np] covered by (possibly overlapping) blocks of
idamnjanovic@61 5 % size BLOCKSIZE=[M1 M2 ... Mp]. The blocks start at position (1,1,..,1)
idamnjanovic@61 6 % and are shifted between them by steps of size STEPSIZE=[S1 S2 ... Sp].
idamnjanovic@61 7 % COUNTCOVER returns a matrix the same size as the signal, containing in
idamnjanovic@61 8 % each entry the number of blocks covering that sample.
idamnjanovic@61 9 %
idamnjanovic@61 10 % See also IM2COLSTEP, COL2IMSTEP, IM2COL.
idamnjanovic@61 11
idamnjanovic@61 12
idamnjanovic@61 13 % Ron Rubinstein
idamnjanovic@61 14 % Computer Science Department
idamnjanovic@61 15 % Technion, Haifa 32000 Israel
idamnjanovic@61 16 % ronrubin@cs
idamnjanovic@61 17 %
idamnjanovic@61 18 % August 2008
idamnjanovic@61 19
idamnjanovic@61 20
idamnjanovic@61 21 cnt = ones(sz);
idamnjanovic@61 22 for k = 1:length(sz)
idamnjanovic@61 23
idamnjanovic@61 24 % this code is modified from function NDGRID, so it computes one
idamnjanovic@61 25 % output argument of NDGRID at a time (to conserve memory)
idamnjanovic@61 26 ids = (1:sz(k))';
idamnjanovic@61 27 s = sz; s(k) = [];
idamnjanovic@61 28 ids = reshape(ids(:,ones(1,prod(s))),[length(ids) s]);
idamnjanovic@61 29 ids = permute(ids,[2:k 1 k+1:length(sz)]);
idamnjanovic@61 30
idamnjanovic@61 31 cnt = cnt .* max( min(floor((ids-1)/stepsize(k)),floor((sz(k)-blocksize(k))/stepsize(k))) - ...
idamnjanovic@61 32 max(ceil((ids-blocksize(k))/stepsize(k)),0) + 1 , 0 );
idamnjanovic@61 33 end