annotate Problems/private/countcover.m @ 16:41a5a3c26961

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