# wdcbm2

Thresholds for wavelet 2-D using Birgé-Massart strategy

## Syntax

```[THR,NKEEP] = wdcbm2(C,S,ALPHA,M) wdcbm2(C,S,ALPHA) wdcbm2(C,S,ALPHA,prod(S(1,:))) ```

## Description

`[THR,NKEEP] = wdcbm2(C,S,ALPHA,M)` returns level-dependent thresholds `THR` and numbers of coefficients to be kept `NKEEP`, for de-noising or compression. `THR` is obtained using a wavelet coefficients selection rule based on the Birgé-Massart strategy.

`[C,S]` is the wavelet decomposition structure of the image to be de-noised or compressed, at level ```j = size(S,1)-2```.

`ALPHA` and `M` must be real numbers greater than 1.

`THR` is a matrix 3 by `j`; `THR(:,i)` contains the level dependent thresholds in the three orientations: horizontal, diagonal, and vertical, for level i.

`NKEEP` is a vector of length `j`; `NKEEP(i)` contains the number of coefficients to be kept at level i.

j, `M` and `ALPHA` define the strategy:

• At level `j`+1 (and coarser levels), everything is kept.

• For level i from 1 to `j`, the ni largest coefficients are kept with ni = `M `/ (j+2-i)ALPHA.

Typically `ALPHA` = 1.5 for compression and `ALPHA` = 3 for de-noising.

A default value for `M` is `M` = `prod(S(1,:))`, the length of the coarsest approximation coefficients, since the previous formula leads for i = j+1, to nj+1 = `M` = `prod(S(1,:))`.

Recommended values for `M` are from `prod(S(1,:))` to `6*prod(S(1,:))`.

`wdcbm2(C,S,ALPHA)` is equivalent to `wdcbm2(C,S,ALPHA,prod(S(1,:)))`.

## Examples

```% Load original image. load detfingr; nbc = size(map,1); % Perform a wavelet decomposition of the image % at level 3 using sym4. wname = 'sym4'; lev = 3; [c,s] = wavedec2(X,lev,wname); % Use wdcbm2 for selecting level dependent thresholds % for image compression using the adviced parameters. alpha = 1.5; m = 2.7*prod(s(1,:)); [thr,nkeep] = wdcbm2(c,s,alpha,m) thr = 21.4814 46.8354 40.7907 21.4814 46.8354 40.7907 21.4814 46.8354 40.7907 nkeep = 624 961 1765 % Use wdencmp for compressing the image using the above % thresholds with hard thresholding. [xd,cxd,sxd,perf0,perfl2] = ... wdencmp('lvd',c,s,wname,lev,thr,'h'); % Plot original and compressed images. colormap(pink(nbc)); subplot(221), image(wcodemat(X,nbc)), title('Original image') subplot(222), image(wcodemat(xd,nbc)), title('Compressed image') xlab1 = ['2-norm rec.: ',num2str(perfl2)]; xlab2 = [' % -- zero cfs: ',num2str(perf0), ' %']; xlabel([xlab1 xlab2]); ``` ## References

Birgé, L.; P. Massart (1997). “From model selection to adaptive estimation,” in D. Pollard (ed), Festchrift for L. Le Cam, Springer, pp. 55–88. 