# WaveletBestBasis

WaveletBestBasis[dwd]

computes a best basis representation in the DiscreteWaveletData object dwd.

WaveletBestBasis[dwd,cspec]

computes a best basis representation using the cost specification cspec.

# Details and Options • WaveletBestBasis[dwd] returns a DiscreteWaveletData odwd object where the optimal basis has been computed and will be used by functions such as InverseWaveletTransform, WaveletListPlot, etc.
• Properties of the DiscreteWaveletData odwd can be found using odwd["prop"].
• Properties related to best basis include:
•  "BasisIndex" wavelet indices used for inverse transform "BestBasisBlockView" block grid view of best basis "BestBasisCostValues" cost value for each wavelet coefficient "TreeView" tree view of decomposition with best basis highlighted
• WaveletBestBasis[dwd] is equivalent to WaveletBestBasis[dwd,"ShannonEntropy"].
• Possible cspec values include:
•  "ShannonEntropy" Shannon entropy "LogEnergy" log energy {"Norm",p} norm like for and for {"Threshold",δ} number of elements above fn apply fn to each coefficient array to get a cost value
• A cost function fn must satisfy fn[{a1,,am,b1,,bn}]fn[{a1,,am}]+fn[{b1,,bn}] and fn[{0,}]0.
• The best basis is a complete basis for the wavelet decomposition giving the least total cost.

# Examples

open allclose all

## Basic Examples(1)

Compute an optimal wavelet basis:

Compare default basis with best basis in a tree plot of all coefficients:

## Scope(11)

### Basic Uses(6)

Compute an optimal wavelet basis for vector data:

The best basis is stored in the resulting DiscreteWaveletData object:

Show the coefficient array corresponding to each index in the basis:

Wavelet packet transforms give a DiscreteWaveletData object that includes a default basis:

The basis includes all coefficients at the highest level of refinement:

WaveletBestBasis gives a new DiscreteWaveletData object with a different, optimal basis:

Compute best basis for packet transforms with any number of levels of refinement:

Compute wavelet basis, minimizing log-energy for an image:

Compare default basis with best basis in a hierarchical grid layout of coefficient images:

Compute best basis with custom cost function:

Choose basis with fewest coefficients lying between -1 and 1:

Count values lying between -1 and 1 in default basis:

Best basis:

WaveletBestBasis gives the optimal basis among all possible wavelet bases:

Recursively enumerate all possible wavelet bases for levels of refinement:

Show the 5 possible wavelet bases for 2 levels of refinement:

The number of possible bases grows extremely quickly as a function of refinement level:

Cost value of optimal basis:

Distribution of cost values of a random sample of 1000 bases:

### Cost Functions(5)

Apply cost functions to coefficients with fixed total energy:

Plot cost as a function of first component energy for "ShannonEntropy":

"LogEnergy":

{"Norm",p}:

{"Threshold",δ}:

In general, each cost function can lead to a different best basis:

Plot distribution of energy among best basis coefficient values for each cost function:

Different cost functions often lead to similar best bases:

Define a custom cost function that favors coefficients that are nearer to integers:

Best basis for list data using custom cost function:

The computed cost value for the {} coefficient is the custom cost value of the original data:

Cost value of the best basis coefficients:

The best basis coefficients are clustered around integers:

Reproduce the built-in cost functions as custom ones:

"ShannonEntropy":

"LogEnergy":

"Norm":

"Threshold":

## Generalizations & Extensions(2)

Explicitly specify the full wavelet basis:

The specified basis is taken to be the best basis:

Select a basis containing the specified wavelet indexes:

The smallest full basis containing the specified indexes is chosen:

## Applications(3)

### Compression(3)

Use WaveletBestBasis to choose a wavelet basis for threshold-based data compression:

Use a hard threshold of 0.1:

Count nonzero values in thresholded coefficients as a measure of compression:

Compare with compression by thresholding original data:

Plot original and reconstructed data:

Compare threshold-based compression for various threshold values :

Use the same threshold value for best basis selection and thresholding:

Show reconstructed data along with the number of nonzero values as a measure of compression:

Length of uncompressed original data:

Simple lossy image compression for various threshold values :

Show reconstructed data along with the number of nonzero values as a measure of compression:

Total number of pixel values in all channels of original image:

## Properties & Relations(4)

The best basis coefficients typically contain fewer, larger nonzero values than the original data:

Compare default basis for wavelet packet transforms with best basis:

Compare with the basis for non-packet wavelet transforms:

Non-packet transforms give a DiscreteWaveletData object with a permanently fixed basis:

The basis includes the detail coefficients {,1} and the last coarse coefficient {,0}:

The result of WaveletBestBasis[dwd] has exactly the same wavelet coefficients as dwd:

Only the wavelet basis is different:

The {} coefficient of "BestBasisCostValues" is the cost value of the original data:

Directly compute log-energy from the data:

The log-energy of the best basis is lower than that of the data:

## Possible Issues(5)

DiscreteWaveletTransform does not compute the full tree of wavelet coefficients: Use DiscreteWaveletPacketTransform to get the full tree:

The cost function must be additive with respect to Join: The specified function is not additive:

Modify the cost function to be additive:

The cost function must be zero for zero-valued coefficients: Modify the cost function to be compatible:

The best basis algorithm requires numeric coefficients: Use specific numerical values:

An explicit basis specification wind needs to be consistent: A basis cannot include both {1} and {1,0} since {1,0} can be computed from {1}:

Select a basis using a consistent wind specification:

Introduced in 2010
(8.0)
{"ft_lang_label":"__label__en","ft_lang_prob":0.78752357,"math_prob":0.91792357,"size":5492,"snap":"2020-45-2020-50","text_gpt3_token_len":1156,"char_repetition_ratio":0.18367347,"word_repetition_ratio":0.051572327,"special_character_ratio":0.19064093,"punctuation_ratio":0.10208562,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9861408,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],"im_url_duplicate_count":[null,5,null,5,null,5,null,5,null,5,null,5,null,5,null,5,null,4,null,4,null,4,null,4,null,4,null,4,null,4,null,4,null,4,null,4,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-10-27T01:03:54Z\",\"WARC-Record-ID\":\"<urn:uuid:b7e8cff8-d0ea-4747-8af3-756998c108e7>\",\"Content-Length\":\"162805\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:ba6253f8-e1a9-4057-a8cd-2a49f429fafc>\",\"WARC-Concurrent-To\":\"<urn:uuid:d4d523e5-bf34-4c66-83ea-054fdaa62763>\",\"WARC-IP-Address\":\"140.177.205.163\",\"WARC-Target-URI\":\"https://reference.wolfram.com/language/ref/WaveletBestBasis.html\",\"WARC-Payload-Digest\":\"sha1:QTXWNOK3QR7WJDAXJV7TFWB5YH5P2GSS\",\"WARC-Block-Digest\":\"sha1:ZPBWZFAGZYMVD2NOQRYV4FXTFZRXPGNI\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-45/CC-MAIN-2020-45_segments_1603107892710.59_warc_CC-MAIN-20201026234045-20201027024045-00641.warc.gz\"}"}