Mercurial > hg > smallbox
diff util/sparco utils/genSampling.m @ 77:62f20b91d870
add routines from sparco problems privite folder to {root}\util
some changes to ksvd vs rlsdla image denoising example
author | Ivan <ivan.damnjanovic@eecs.qmul.ac.uk> |
---|---|
date | Fri, 25 Mar 2011 14:01:50 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/util/sparco utils/genSampling.m Fri Mar 25 14:01:50 2011 +0000 @@ -0,0 +1,53 @@ +function [minIntrVec,stat,actpctg] = genSampling(pdf,iter,tol) + +%[mask,stat,N] = genSampling(pdf,iter,tol) +% +% a monte-carlo algorithm to generate a sampling pattern with +% minimum peak interference. The number of samples will be +% sum(pdf) +- tol +% +% pdf - probability density function to choose samples from +% iter - number of tries +% tol - the deviation from the desired number of samples in samples +% +% returns: +% mask - sampling pattern +% stat - vector of min interferences measured each try +% actpctg - actual undersampling factor +% +% (c) Michael Lustig 2007 + +% This file is used with the kind permission of Michael Lustig +% (mlustig@stanford.edu), and originally appeared in the +% SparseMRI toolbox, http://www.stanford.edu/~mlustig/ . +% +% $Id: genSampling.m 1040 2008-06-26 20:29:02Z ewout78 $ + +% h = waitbar(0); + +pdf(find(pdf>1)) = 1; +K = sum(pdf(:)); + +minIntr = 1e99; +minIntrVec = zeros(size(pdf)); + +for n=1:iter + tmp = zeros(size(pdf)); + while abs(sum(tmp(:)) - K) > tol + tmp = rand(size(pdf))<pdf; + end + + TMP = ifft2(tmp./pdf); + if max(abs(TMP(2:end))) < minIntr + minIntr = max(abs(TMP(2:end))); + minIntrVec = tmp; + end + stat(n) = max(abs(TMP(2:end))); + % waitbar(n/iter,h); +end + +actpctg = sum(minIntrVec(:))/prod(size(minIntrVec)); + +% close(h); + +