comparison util/sparco utils/pwsmoothfield.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
comparison
equal deleted inserted replaced
76:d052ec5b742f 77:62f20b91d870
1 function f = pwsmoothfield(n,var,alpha)
2 % PWSMOOTHFIELD(N,VAR,ALPHA)
3 % Generate an image of piecewise smooth filtered white noise
4 %
5 % N = sidelength of the field in pixels
6 % VAR = variance of original white nose
7 % ALPHA = fraction of FFT coefficents to keep
8 %
9 % Returns an N-by-N array
10 %
11 % This file is used with the kind permission of Stephen J. Wright
12 % (swright@cs.wisc.edu), and was originally included in the GPSR
13 % v1.0 distribution: http://www.lx.it.pt/~mtf/GPSR .
14
15 % $Id: pwsmoothfield.m 1040 2008-06-26 20:29:02Z ewout78 $
16
17 f = sqrt(var)*randn(n);
18 F = fft2(f);
19 a = ceil(n*alpha/2);
20 b = fix(n*(1-alpha));
21 F(a+1:a+b,:) = 0;
22 F(:,a+1:a+b) = 0;
23 f = real(ifft2(F));
24
25 for i = 1:n
26 for j = 1:n
27 if (j/n >= 15*(i/n - 0.5)^3 + 0.4)
28 f(i,j) = f(i,j) + sqrt(var);
29 end
30 end
31 end
32