PRO WADNOISE, sig, numrow, numcol, noise_type, noise_lev, TT ;+ ;NAME: ; WADNOISE ; ;PURPOSE: ; To add noise to the "sig" data array or image. ; ;CATEGORY: ; Wavelets ; ;CALLING SEQUENCE: ; WADNOISE, sig, numrow, numcol, noise_type, noise_level ; ;INPUTS: ; sig = current data array/signal ; numrow = number of rows ; numcols = number of columns ; noise_type = uniform (2) or normal (1) or Poisson (3) (default = 1) ; noise_lev = amplitude of noise (default = 1) ; ;OUTPUTS: ; sig = now noisy data array/signal/image ; TT = 'I' if image and 'S' if signal ; ;EXAMPLE: ; IDL> ;Truncate sig array appropriately and get QMF ; IDL> WINTWAVE, sig, WaveType, ParVal, QMF, LD ; IDL> ncol = WGETSIZE(sig, nrow) ; IDL> tt = 'S' if 1D dataset or tt = 'I' if 2D dataset ; IDL> WADNOISE, sig, nrow, ncol, noise_type, noise_lev, tt ; IDL> If tt EQ 'S' then WPLOTIT, st, 1, sig ELSE WPLOTIT, st, 10, sig ; ;MODIFICATION HISTORY: ; Amara Graps September 1995. ; copyright (c) Amara Graps 1995, 1996. ;- CASE noise_type OF 2: BEGIN ;Uniform distribution noise x_noise = noise_lev*WRAND(seed, numrow, numcol) END ;Uniform 1: BEGIN ;Normal distribution noise x_noise = noise_lev*WRANDN(seed, numrow, numcol) END ;Normal 3: BEGIN ;Poisson distribution noise ;Pick a Poisson distribution around .5 (want 0<1.0) a = REPLICATE(.5, numrow, numcol) x_noise = noise_lev*WPOISIMG(a, out="float") END ;Poisson ELSE: print, 'noise_type for WADNOISE not defined!' ENDCASE ;noise_type TT = WSIGTYPE(sig, len, error) CASE error OF 1: BEGIN ;Valid array or matrix CASE TT OF 'I': BEGIN sig = sig + BYTE(x_noise) END 'S': BEGIN sig = sig + x_noise END ENDCASE ;TT END ;valid array or matrix ELSE: PRINT, 'Not valid data/signal array or matrix!' ENDCASE ;error END ;of procedure wadnoise ;**********************************************