function WFPTWP, basis,x,qmf ;+ ; NAME: ; WFPTWP ; ; PURPOSE: ; This function analyzes an image into specific wavelet packet basis. ; ; CATEGORY: ; Wavelets ; ; CALLING SEQUENCE: ; coef = WFPTWP(basis,x,qmf) ; ; INPUTS: ; basis: tree selecting wavelet packet basis ; x: 1-d image to be transformed into basis ; qmf: quadrature mirror filter ; ; OUTPUTS: ; coef 1-d wavelet packet coeffts in given basis ; ; EXAMPLE: ; ; MODIFICATION HISTORY: ; Written by: Amara Graps December, 1994 ;Translated from MatLab Wavelab routine: fpt_wp.m ;- n = WDYADLNG(x,J) coef = WSHASROW(x) ; The vector is split into high-and-low pass pieces ; recursively, using the splits selected by the ; tree basis ; initialize tree traversal stack stack = FLTARR(100, 2) ; pushdown root of tree k = 1 stack(k-1, *) = TRANSPOSE([0,0]) ; d, b WHILE (k gt 0) DO BEGIN ; pop stack d = stack(k-1, 0) ; depth of this node b = stack(k-1, 1) ; branch at this depth k = k-1 IF (basis(WNODE(d,b)-1) NE 0) THEN BEGIN ; nonterwmminal node lo = 1 + b*n/2^d hi = (b+1)*n/2^d mid = 1 + (2*b+1)*n/(2^(d+1)) ; get channel and split into Hi and Lo Pass sig = coef(lo-1:hi-1) lpchan = WDNDYDLO(sig,qmf) hpchan = WDNDYDHI(sig,qmf) ; store pieces according to Gray code bit = WREM(b,2) IF ( bit) THEN BEGIN coef(lo-1:mid-2) = hpchan coef(mid-1:hi-1) = lpchan END ELSE BEGIN coef(lo-1:mid-2) = lpchan coef(mid-1:hi-1) = hpchan END ; push stack k = k+1 stack(k-1, *) = TRANSPOSE([(d+1), (2*b)]) k = k+1 stack(k-1, *) = TRANSPOSE([(d+1), (2*b+1)]) END ;if END ;while ; ; Algorithm Source: WaveLab Version 0.600 ; WaveLab WWW site: http://playfair.stanford.edu/ ; WaveLab Questions? e-mail wavelab@playfair.stanford.edu ; RETURN, coef END ;***************************************************