function WIPTWP, basis,coef,qmf ;+ ; NAME: ; WIPTWP ; ; PURPOSE: ; This function synthesizes a signal from wavelet packet ; coefficients. ; ; CATEGORY: ; Wavelets ; ; CALLING SEQUENCE: ; x = WIPTWP(btree,coef,qmf) ; ; INPUTS: ; basis basis tree selecting wavelet packet basis ; coef coefficients in that basis ; qmf quadrature mirror filter ; ; OUTPUTS: ; x: 1-d signal reconstructed from coefficients ; ; NOTES: ; 1. qmf filter may be obtained from WMKOFILT ; 2. usually, length(qmf) lt 2^(L+1) ; ; EXAMPLE: ; ; SEE ALSO: ; wfptwp, wmkofilt ; ; MODIFICATION HISTORY: ; Written by: Amara Graps February, 1995 ;Translated from MatLab Wavelab routine: ipt_wp.m ;- n = WDYADLNG(coef,L) x = WSHASROW(coef) ; initialize tree traversal stack stack = FLTARR(2^L, 3) ; pushdown root k = 1 stack(k-1, *) = TRANSPOSE([0,0,0]) WHILE (k gt 0) DO BEGIN ; pop stack d = stack(k-1, 0) b = stack(k-1, 1) marked = stack(k-1, 2) k = k-1 IF (basis(WNODE(d,b)-1) ne 0) THEN BEGIN ; nonterwmminal node IF (marked EQ 0) THEN BEGIN ; first visit to this node, because unmarked ; visit children before reconstructing k = k+1 stack(k-1, *) = TRANSPOSE([d,b,1]) k = k+1 stack(k-1, *) = TRANSPOSE([(d+1), (2*b), 0]) k = k+1 stack(k-1, *) = TRANSPOSE([(d+1), (2*b+1), 0]) END ELSE BEGIN ; second (and last) visit to this node, reconstruct lson = WREM(b,2) ; take care of Gray code lpchan = x(WPACKET(d+1,2*b+lson,n)) hpchan = x(WPACKET(d+1,2*b+(1-lson),n)) s = WUPDYDHI(hpchan,qmf) + WUPDYDLO(lpchan,qmf) x(WPACKET(d,b,n)) = s end ;else END ; if (marked eq 0) END ;WHILE x = WSHLIKE(x,coef) ; ; Algorithm Source: WaveLab Version 0.600 ; WaveLab WWW site: http://playfair.stanford.edu/ ; WaveLab Questions? e-mail wavelab@playfair.stanford.edu ; Comments?e-mail wavelab@playfair.stanford.edu ; RETURN, x END ;***************************************************