annotate examples/private/countcover.m @ 5:f44689e95ea4

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