Products & Services Solutions Academia Support User Community Company

Learn more about Communications Blockset   

Source Coding

Section Overview

Source coding, also known as quantization or signal formatting, is a way of processing data to reduce redundancy or prepare it for later processing. Analog-to-digital conversion and data compression are two categories of source coding.

Source coding divides into two basic procedures: source encoding and source decoding. Source encoding converts a source signal into a digital signal using a quantization method. The symbols in the resulting signal are nonnegative integers in some finite range. Source decoding recovers the original information from the source-coded signal.

For background material on the subject of source coding, see the works listed in Selected Bibliography for Source Coding.

This blockset supports scalar quantization, companders, and differential coding. It does not support vector quantization. You can open the Source Coding library by double-clicking its icon in the main Communications Blockset library.

Supporting functionality in Communications Toolbox also allows you to optimize source-coding parameters for a set of training data. See Optimizing Quantization Parameters in the Communications Toolbox User's Guide for more information about such capabilities.

Representing Quantization Parameters

Scalar quantization is a process that maps all inputs within a specified range to a common value. It maps inputs in a different range of values to a different common value. In effect, scalar quantization digitizes an analog signal. Two parameters determine a quantization: a partition and a codebook. This section describes how blocks represent these parameters.

Partitions

A quantization partition defines several contiguous, nonoverlapping ranges of values within the set of real numbers. To specify a partition as a parameter, list the distinct endpoints of the different ranges in a vector.

For example, if the partition separates the real number line into the sets

then you can represent the partition as the three-element vector

[0,1,3]

The length of the partition vector is one less than the number of partition intervals.

Codebooks

A codebook tells the quantizer which common value to assign to inputs that fall into each range of the partition. Represent a codebook as a vector whose length is the same as the number of partition intervals. For example, the vector

[-1,0.5,2,3]

is one possible codebook for the partition [0,1,3].

Quantizing a Signal

This section shows how the Quantizing Encoder and Quantizing Decoder blocks use the partition and codebook parameters. The examples here are analogous to Scalar Quantization Example 1 and Scalar Quantization Example 2 in the Communications Toolbox documentation.

Scalar Quantization Example 1

The figure below shows how the Quantizing Encoder block uses the partition and codebook as defined above to map a real vector to a new vector whose entries are either -1, 0.5, 2, or 3. In the Scope window, the bottom signal is the quantization of the (original) top signal.

To open the completed model, click here in the MATLAB Help browser. To build the model, gather and configure these blocks:

Connect the blocks as shown in the figure. From the model window's Simulation menu, select Configuration parameters. In the Configuration Parameters dialog box, set Stop time to 12. Running the model produces a scope image similar to the one above. (To make the axis ranges and title exactly match those in the figure, right-click each plot area in the scope and select Axes properties.)

Scalar Quantization Example 2

This example, shown in the figure below, illustrates the nature of scalar quantization more clearly. It samples and quantizes a sine wave and then plots the original (top) and quantized (bottom) signals. The plot contrasts the smooth sine curve with the polygonal curve of the quantized signal. The vertical coordinate of each flat part of the polygonal curve is a value in the Quantization codebook vector.

To open the completed model, click here in the MATLAB Help browser. To build the model, gather and configure these blocks:

Connect the blocks as shown in the figure. From the model window's Simulation menu, select Configuration parameters. In the Configuration Parameters dialog box, set Stop time to 2*pi. Running the model produces the scope image as shown above. (To make the axis ranges and title exactly match those in the figure, right-click each plot area in the scope and select Axes properties.)

Determining Which Interval Each Input Is In

The Quantizing Encoder block also returns a signal, at the first output port, that tells which interval each input is in. For example, the model below shows that the input entries lie within the intervals labeled 0, 6, and 5, respectively. Here, the 0th interval consists of real numbers less than or equal to 3; the 6th interval consists of real numbers greater than 8 but less than or equal to 9; and the 5th interval consists of real numbers greater than 7 but less than or equal to 8.

To open the completed model, click here in the MATLAB Help browser. To build the model, gather and configure these blocks:

Connect the blocks as shown above. From the model window's Simulation menu, select Configuration parameters. In the Configuration Parameters dialog box, set Stop time to 10. Running the model produces the display numbers as shown in the figure.

You can continue this example by branching the first output of the Quantizing Encoder block, connecting one branch to the input port of the Quantizing Decoder block, and connecting the output of the Quantizing Decoder block to another Display block. If the two source coding blocks' Quantization codebook parameters match, the output of the Quantizing Decoder block is the same as the second output of the Quantizing Encoder block. Thus the Quantizing Decoder block partially duplicates the functionality of the Quantizing Encoder block, but requires different input data and fewer parameters.

Companding a Signal

In certain applications, such as speech processing, it is common to use a logarithm computation, called a compressor, before quantizing. The inverse operation of a compressor is called an expander. The combination of a compressor and expander is called a compander.

This blockset supports two kinds of companders: µ-law and A-law companders. The reference pages for the A-Law Compressor, A-Law Expander, Mu-Law Compressor, and Mu-Law Expander blocks list the relevant expander and compressor laws.

Example: Using a µ-Law Compander

This example quantizes an exponential signal in two ways and compares the resulting mean-square distortions. To create the signal in the MATLAB workspace, execute these commands:

sig = -4:.1:4;
sig = exp(sig'); % Exponential signal to quantize

The model in the following figure performs two computations. One computation uses the Quantizing Encoder block with a partition consisting of length-one intervals. The second computation uses the Mu-Law Compressor block to implement a µ-law compressor, the Quantizing Encoder block to quantize the compressed data and, finally, the Mu-Law Expander block to expand the quantized data.

To open the completed model, click here in the MATLAB Help browser. To build the model, gather and configure these blocks:

Connect the blocks as shown above. From the model window's Simulation menu, select Configuration parameters. In the Configuration Parameters dialog box, set Stop time to 80. Run the model and execute these commands:

distor = sum((nocompander-sig).^2)/length(sig);
distor2 = sum((withcompander-sig).^2)/length(sig);
[distor distor2]

ans =

    0.5348    0.0397

This output shows that the distortion is smaller for the second scheme. This is because equal-length intervals are well suited to the logarithm of the data but not as well suited to the data itself.

Relevant Demos

The following audio processing demos, located in the Signal Processing Blockset documentation, highlight different techniques for source coding.

Selected Bibliography for Source Coding

[1] Couch, Leon W., II, Digital and Analog Communication Systems, 6th edition, Upper Saddle River, NJ, Prentice Hall, 2001.

[2] Kondoz, A.M., Digital Speech, Chichester, England, John Wiley & Sons, 1994.

[3] Sklar, Bernard. Digital Communications: Fundamentals and Applications, Englewood Cliffs, NJ, Prentice Hall, 1988.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS