annotate util/sparco utils/pwsmoothfield.m @ 82:138f7f0fdcdf

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