function WUPKCOEF, basis,wp ;+ ; NAME: ; WUPKCOEF ; ; PURPOSE: ; This function extracts the basis coefficients from packet table. ; ; CATEGORY: ; Wavelets. ; ; CALLING SEQUENCE: ; x = WUPKCOEF(basis,wp) ; ; INPUTS: ; basis = basis tree ; wp = packet table (wavelet- or cosine-) ; ; OUTPUTS: ; x = coefficients of signal in that basis ; ; ; MODIFICATION HISTORY: ; Written by: Amara Graps September, 1995 ;Translated from MatLab Wavelab routine: unpackbasiscoeff.m ;- tt = SIZE(wp) L = tt(1) ;number of columns n = tt(2) ;number of rows x= FLTARR(n) ; ; initialize tree traversal stack ; dstack = FLTARR(2^L) bstack = FLTARR(2^L) k = 1 dstack(k-1) = 0 bstack(k-1) = 0 ; WHILE (k gt 0) DO BEGIN d = dstack(k-1) b = bstack(k-1) k=k-1 IF ((basis(WNODE(d,b)-1) eq 0) ) THEN BEGIN ; terminal node x(WPACKET(d,b,n)) = TRANSPOSE(wp(d, WPACKET(d,b,n))) ENDIF ELSE BEGIN k = k+1 dstack(k-1) = d+1 bstack(k-1) = 2*b k = k+1 dstack(k-1) = d+1 bstack(k-1) = 2*b+1 END ;ELSE END ;WHILE ; ; Algorithm Source: WaveLab Version 0.600 ; WaveLab WWW site: http://playfair.stanford.edu/ ; WaveLab Questions? e-mail wavelab@playfair.stanford.edu ; RETURN, x END ;***************************************************