function WPKBCOEF, basis,opkt,x ;+ ; NAME: ; WPKBCOEF ; ; PURPOSE: ; This function stuffS basis coefficients into packet table. ; ; CATEGORY: ; Wavelets. ; ; CALLING SEQUENCE: ; pkt = WPKBCOEF(basis,opkt,x) ; ; INPUTS: ; basis = basis tree selecting basis the coefficients come from ; opkt = wavelet or cosine packet table ; x = 1-d signal; coefficients in the basis of btree ; ; OUTPUTS: ; pkt = new packet table with coefficients in specified ; basis filled in from x ; ; ; MODIFICATION HISTORY: ; Written by: Amara Graps September, 1995 ;Translated from MatLab Wavelab routine: wpkbcoef.m ;- t = SIZE(opkt) L = t(1) ;number of columns n = t(2) ;number of rows pkt = opkt ; initialize tree traversal stack dstack = FLTARR(2^L) bstack = FLTARR(2^L) ; pushdown root k = 1 dstack(k-1) = 0 bstack(k-1) = 0 WHILE(k GT 0) DO BEGIN ; pop stack d = dstack(k-1) b = bstack(k-1) k = k-1 IF ((basis(WNODE(d,b)-1) EQ 0) ) THEN BEGIN ; termminal node: extract coeff pkt(d, WPACKET(d,b,n)) = TRANSPOSE(x(WPACKET(d,b,n))) ENDIF ELSE BEGIN ; nontermminal node: visit children 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 ENDELSE END ;while ; ; Algorithm Source: WaveLab Version 0.600 ; WaveLab WWW site: http://playfair.stanford.edu/ ; WaveLab Questions? e-mail wavelab@playfair.stanford.edu ; RETURN, pkt END ;***************************************************