Main Content

arithdeco

Decode binary code by arithmetic decoding

Description

dseq = arithdeco(code,counts,len) decodes the binary arithmetic code in code to recover the corresponding sequence of len symbols. The input countsspecifies the statistics of the source by listing the number of times each symbol of the source alphabet occurs in a test data set. code must be an output of the arithenco function.

example

Examples

collapse all

Using a source with a two-symbol alphabet, produce a test data set in which 99% of the symbols are 1s. Encode 1000 symbols from this source to produce a code vector with less than 1000 elements. The actual number of elements in the encoded sequence varies depending on the particular random sequence.

Specify for symbol 1 from the source alphabet to occur 99 times in the test data set.

counts = [99 1];

Generate a random sequence of length 1000.

len = 1000;
seq = randsrc(1,len,[1 2; .99 .01]);

Encode the random sequence. Then, decode the encoded sequence.

code = arithenco(seq,counts);
dseq = arithdeco(code,counts,length(seq));

Verify that the decoded sequence matches the original random sequence.

isequal(seq,dseq)
ans = logical
   1

Input Arguments

collapse all

Binary arithmetic code, specified as a nonnegative binary row vector. This value must be a binary arithmetic code produced by the arithenco function.

Data Types: double

Statistics of symbols, specified as a positive numeric vector. This input specifies the number of times each symbol of the source alphabet occurs in a test data set.

Data Types: double

Length of the sequence to decode, specified as a positive scalar.

Data Types: double

Output Arguments

collapse all

Decoded arithmetic code with a sequence of len source symbols, specified as a positive numeric row vector.

Algorithms

The arithdeco function uses the algorithm described in [1].

References

[1] Sayood, Khalid. Introduction to Data Compression. 2nd ed. San Francisco: Morgan Kaufmann Publishers, 2000.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced before R2006a

expand all

See Also

Functions