annotate DL/RLS-DLA/private/pwsmoothfield.m @ 63:e08af264ef93

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