function WSTATREE, pkt,Entropy,par ;+ ;NAME: ; WSTATREE ; ;PURPOSE: ; To build tree with entropy numbers. ; ;CATEGORY: ; Wavelets. ; ;CALLING SEQUENCE: ; stree = WSTATREE(pkt,Entropy,par) ; ;INPUTS: ; pkt packet table [wavelet or cosine packet] (n x L) ; Entropy type of entropy to use: options are ; 'Entropy' -- Coifman-Wickerhauser ; 'l^p' -- sum th_i^p, 0 lt p lt 2, p = par ; 'N(eps)' -- # ge eps, eps = par ; 'Risk' -- sum min(th_i^2,eps^2), eps=par ; 'SURE' -- SURE(Thresholding), thresh = par ; (Stein's unbiased estimate of risk) ; par extra parameter for 'L^P', 'N(EPS)', 'SURE' Entropy ; calculation ; ;OUTPUTS: ; stree stat tree of entropy numbers. ; tree(WNODE(d,b)) contains entropy of WPACKET(d,b,n) ; ;RESTRICTIONS: ; None. ; ;EXAMPLE: ; ;SEE ALSO: ; wbbasis, wplbtree ; ;MODIFICATION HISTORY: ; Written by: Amara Graps December 1994/August1995 ;Translated from MatLab Wavelab routine: calcstattree.m ;- t = SIZE(pkt) L = t(1) ;number of columns n = t(2) ;number of rows ;Note Matlab's [n,L]=size(pkt) results in: ;n = num of rows, L = num of cols D = L-1 tree = FLTARR(2^L-1) ss = WNNORM(pkt(0,*)) WCALCEPS, eps ;calculate the floating number tolerance CheckEntr = STRCOMPRESS(Entropy,/remove_all) ;remove white space CheckEntr = STRUPCASE(CheckEntr) ;make upper case CASE CheckEntr OF 'ENTROPY': BEGIN for dd=0, D do begin for b=0, (2^dd-1) do begin p = (pkt(dd, WPACKET(dd,b,n)) /ss)^2 tree(WNODE(dd,b)-1) = - WSUM(WSUM(p * ALOG(eps+p))) END ;b END ;dd END ;'ENTROPY' 'L^P': BEGIN ; par = p = exponent FOR dd=0, D DO BEGIN FOR b=0, (2^dd-1) DO BEGIN p = ABS(pkt(dd,WPACKET(dd,b,n)) /ss) tree(WNODE(dd,b)-1) = WSUM(p^par) END ;b END ;dd END ;'L^P' 'N(EPS)': begin ; par = eps FOR dd=0,D DO BEGIN FOR b=0, (2^dd-1) DO BEGIN p = ABS(pkt(dd, WPACKET(dd,b,n))) tree(WNODE(dd,b)-1) = WSUM( p GT par ) END ;b END ;dd END ;'N(EPS)' 'RISK': BEGIN FOR dd=0,D DO BEGIN FOR b=0,(2^dd-1) DO BEGIN p = pkt(dd,WPACKET(dd,b,n))^2 tree(WNODE(dd,b)-1) = WSUM( p /(1+ p) ) END ;b END ;dd END ;'RISK' 'SURE': BEGIN tt = par^2 ; par = threshold FOR dd=0,D DO BEGIN dim = n /(2^dd) FOR b=0, (2^dd-1) DO BEGIN p = pkt(dd, WPACKET(dd,b,n))^2 ngt = WSUM( p gt tt) nlt = dim - ngt slt = WSUM( p * ( p le tt )) tree(WNODE(dd,b)-1) = dim - 2*nlt + tt*ngt + slt END ;b END ;dd END ;'SURE' ELSE: BEGIN PRINT, 'In WSTATREE: unknown Entropy request.' PRINT, 'Request<<'+Entropy+'>>' PRINT, 'I only know how to do:' PRINT, ' Entropy, l^p, N(eps), Risk' END ;else ENDCASE ;Case Checktype ; ; Algorithm Source: WaveLab Version 0.600 ; WaveLab WWW site: http://playfair.stanford.edu/ ; WaveLab Questions? e-mail wavelab@playfair.stanford.edu ; RETURN, tree End ;***************************************************