comparison DL/RLS-DLA/private/pwsmoothfield.m @ 60:ad36f80e2ccf

(none)
author idamnjanovic
date Tue, 15 Mar 2011 12:20:59 +0000
parents
children
comparison
equal deleted inserted replaced
59:23f9dd7b9d78 60:ad36f80e2ccf
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