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