Mercurial > hg > smallbox
annotate util/ksvd utils/countcover.m @ 221:c1efdd5d6250 luisf_dev
added ompbox_fast as sparse approximation solver, which calls the functions in ompbox using the fastest implementation
author | Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk> |
---|---|
date | Wed, 11 Apr 2012 16:13:08 +0100 |
parents | c3eca463202d |
children |
rev | line source |
---|---|
idamnjanovic@70 | 1 function cnt = countcover(sz,blocksize,stepsize) |
idamnjanovic@70 | 2 %COUNTCOVER Covering of signal samples by blocks |
idamnjanovic@70 | 3 % CNT = COUNTCOVER(SZ,BLOCKSIZE,STEPSIZE) assumes a p-dimensional signal |
idamnjanovic@70 | 4 % of size SZ=[N1 N2 ... Np] covered by (possibly overlapping) blocks of |
idamnjanovic@70 | 5 % size BLOCKSIZE=[M1 M2 ... Mp]. The blocks start at position (1,1,..,1) |
idamnjanovic@70 | 6 % and are shifted between them by steps of size STEPSIZE=[S1 S2 ... Sp]. |
idamnjanovic@70 | 7 % COUNTCOVER returns a matrix the same size as the signal, containing in |
idamnjanovic@70 | 8 % each entry the number of blocks covering that sample. |
idamnjanovic@70 | 9 % |
idamnjanovic@70 | 10 % See also IM2COLSTEP, COL2IMSTEP, IM2COL. |
idamnjanovic@70 | 11 |
idamnjanovic@70 | 12 |
idamnjanovic@70 | 13 % Ron Rubinstein |
idamnjanovic@70 | 14 % Computer Science Department |
idamnjanovic@70 | 15 % Technion, Haifa 32000 Israel |
idamnjanovic@70 | 16 % ronrubin@cs |
idamnjanovic@70 | 17 % |
idamnjanovic@70 | 18 % August 2008 |
idamnjanovic@70 | 19 |
idamnjanovic@70 | 20 |
idamnjanovic@70 | 21 cnt = ones(sz); |
idamnjanovic@70 | 22 for k = 1:length(sz) |
idamnjanovic@70 | 23 |
idamnjanovic@70 | 24 % this code is modified from function NDGRID, so it computes one |
idamnjanovic@70 | 25 % output argument of NDGRID at a time (to conserve memory) |
idamnjanovic@70 | 26 ids = (1:sz(k))'; |
idamnjanovic@70 | 27 s = sz; s(k) = []; |
idamnjanovic@70 | 28 ids = reshape(ids(:,ones(1,prod(s))),[length(ids) s]); |
idamnjanovic@70 | 29 ids = permute(ids,[2:k 1 k+1:length(sz)]); |
idamnjanovic@70 | 30 |
idamnjanovic@70 | 31 cnt = cnt .* max( min(floor((ids-1)/stepsize(k)),floor((sz(k)-blocksize(k))/stepsize(k))) - ... |
idamnjanovic@70 | 32 max(ceil((ids-blocksize(k))/stepsize(k)),0) + 1 , 0 ); |
idamnjanovic@70 | 33 end |