tomwalters@0: % method of class @signal tomwalters@0: % function sig=gennoise tomwalters@0: % sig: original @signal with length and samplerate tomwalters@0: % tomwalters@0: % This function generates 1/f spatial noise, with a normal error tomwalters@0: % distribution (the grid must be at least 10x10 for the errors to be normal). tomwalters@0: % 1/f noise is scale invariant, there is no spatial scale for which the tomwalters@0: % variance plateaus out, so the process is non-stationary. tomwalters@0: % tomwalters@0: % BETA defines the spectral distribution. tomwalters@0: % Spectral density S(f) = N f^BETA tomwalters@0: % (f is the frequency, N is normalisation coeff). tomwalters@0: % BETA = 0 is random white noise. tomwalters@0: % BETA -1 is pink noise tomwalters@0: % BETA = -2 is Brownian noise tomwalters@0: % The fractal dimension is related to BETA by, D = (6+BETA)/2 tomwalters@0: % tomwalters@0: % tomwalters@0: % RETURN VALUE: tomwalters@0: % sig: @signal tomwalters@0: % tomwalters@0: % (c) 2007 ISVR University of Southampton tomwalters@0: % Stefan Bleeck (bleeck@gmail.com) tomwalters@0: % $Date: 2003/01/25 12:47:43 $ tomwalters@0: % $Revision: 1.4 $ tomwalters@0: tomwalters@0: % function sig=gennoise(sig,beta,rms_desired) tomwalters@0: function sig=gennoise(sig,beta) tomwalters@0: tomwalters@0: % if nargin<3 tomwalters@0: % rms_desired=-1; % tomwalters@0: % end tomwalters@0: if nargin<2 tomwalters@0: beta=0; % tomwalters@0: end tomwalters@0: tomwalters@0: sr=getsr(sig); tomwalters@0: len=getnrpoints(sig); tomwalters@0: tomwalters@0: dots=spatialPattern([1,len],beta); tomwalters@0: tomwalters@0: sig=setvalues(sig,dots); tomwalters@0: sig=setname(sig,sprintf('Noise with beta = %2.1f',beta)); tomwalters@0: tomwalters@0: tomwalters@0: % if rms_desired>=0 tomwalters@0: % sig=rms_desired*sig/rms(sig); tomwalters@0: % end tomwalters@0: tomwalters@0: