Mercurial > hg > smallbox
comparison util/ksvd utils/countcover.m @ 70:c3eca463202d
(none)
author | idamnjanovic |
---|---|
date | Wed, 16 Mar 2011 14:16:57 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
69:5f1f436057ca | 70:c3eca463202d |
---|---|
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 % See also IM2COLSTEP, COL2IMSTEP, IM2COL. | |
11 | |
12 | |
13 % Ron Rubinstein | |
14 % Computer Science Department | |
15 % Technion, Haifa 32000 Israel | |
16 % ronrubin@cs | |
17 % | |
18 % August 2008 | |
19 | |
20 | |
21 cnt = ones(sz); | |
22 for k = 1:length(sz) | |
23 | |
24 % this code is modified from function NDGRID, so it computes one | |
25 % output argument of NDGRID at a time (to conserve memory) | |
26 ids = (1:sz(k))'; | |
27 s = sz; s(k) = []; | |
28 ids = reshape(ids(:,ones(1,prod(s))),[length(ids) s]); | |
29 ids = permute(ids,[2:k 1 k+1:length(sz)]); | |
30 | |
31 cnt = cnt .* max( min(floor((ids-1)/stepsize(k)),floor((sz(k)-blocksize(k))/stepsize(k))) - ... | |
32 max(ceil((ids-blocksize(k))/stepsize(k)),0) + 1 , 0 ); | |
33 end |