Matlab Program For Uniform Quantization Encoding Specificity

Posted on

Source Coding Represent Partitions Scalar quantization is a process that maps all inputs within a specified range to a common value. This process 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 and a. A quantization partition defines several contiguous, nonoverlapping ranges of values within the set of real numbers. To specify a partition in the MATLAB ® environment, list the distinct endpoints of the different ranges in a vector.

Matlab Program For Uniform Quantization Encoding Memory. The master’s program in Engineering. Prior programming ability and some. Specific topics. Matlab Program For Uniform Quantization Encoding Specificity. Cambridge Machine Learning Group Publications. Machine Learning Group. Department of Engineering. University of Cambridge. Abstract: Techniques known as Nonlinear Set. Membership prediction, Kinky Inference or Lipschitz Interpolation are fast.

Matlab Program For Uniform Quantization Encoding SpecificityMatlab Program For Uniform Quantization Encoding Specificity

For example, if the partition separates the real number line into the four sets. Codebook = [-1, 0.5, 2, 3]; is one possible codebook for the partition [0,1,3]. Determine Which Interval Each Input Is In The quantiz function also returns a vector that tells which interval each input is in. For example, the output below says 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.

Partition = [3,4,5,6,7,8,9]; codebook = [3,3,4,5,6,7,8,9]; [index,quants] = quantiz([2 9 8],partition,codebook); Optimize Quantization Parameters • • Section Overview Quantization distorts a signal. You can reduce distortion by choosing appropriate partition and codebook parameters. However, testing and selecting parameters for large signal sets with a fine quantization scheme can be tedious. One way to produce partition and codebook parameters easily is to optimize them according to a set of so-called training data. Note The training data you use should be typical of the kinds of signals you will actually be quantizing.

Example: Optimizing Quantization Parameters The lloyds function optimizes the partition and codebook according to the Lloyd algorithm. The code below optimizes the partition and codebook for one period of a sinusoidal signal, starting from a rough initial guess. Then it uses these parameters to quantize the original signal using the initial guess parameters as well as the optimized parameters.

The output shows that the mean square distortion after quantizing is much less for the optimized parameters. The quantiz function automatically computes the mean square distortion and returns it as the third output parameter. Ans = 0.0148 0.0024 Differential Pulse Code Modulation • • • • Section Overview The quantization in the section requires no a priori knowledge about the transmitted signal. In practice, you can often make educated guesses about the present signal based on past signal transmissions. Using such educated guesses to help quantize a signal is known as predictive quantization. The most common predictive quantization method is differential pulse code modulation (DPCM). The functions dpcmenco,, and dpcmopt can help you implement a DPCM predictive quantizer with a linear predictor.

DPCM Terminology To determine an encoder for such a quantizer, you must supply not only a partition and codebook as described in and, but also a predictor. The predictor is a function that the DPCM encoder uses to produce the educated guess at each step. A linear predictor has the form. Note The initial zero in the predictor vector makes sense if you view the vector as the polynomial transfer function of a finite impulse response (FIR) filter. Example: DPCM Encoding and Decoding A simple special case of DPCM quantizes the difference between the signal's current value and its value at the previous step.

Thus the predictor is just y(k) = x (k - 1). The code below implements this scheme. It encodes a sawtooth signal, decodes it, and plots both the original and decoded signals. The solid line is the original signal, while the dashed line is the recovered signals.

The example also computes the mean square error between the original and decoded signals. Note The training data you use with dpcmopt should be typical of the kinds of signals you will actually be quantizing with dpcmenco. Example: Comparing Optimized and Nonoptimized DPCM Parameters This example is similar to the one in the last section. However, where the last example created predictor, partition, and codebook in a straightforward but haphazard way, this example uses the same codebook (now called initcodebook) as an initial guess for a new optimized codebook parameter.

This example also uses the predictive order, 1, as the desired order of the new optimized predictor. The dpcmopt function creates these optimized parameters, using the sawtooth signal x as training data. The example goes on to quantize the training data itself; in theory, the optimized parameters are suitable for quantizing other data that is similar to x. Notice that the mean square distortion here is much less than the distortion in the previous example. Distor = 0.0063 Compand a Signal • • Section Overview 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.

The compand function supports two kinds of companders: µ-law and A-law companders. Its reference page lists both compressor laws. Example: µ-Law Compander The code below quantizes an exponential signal in two ways and compares the resulting mean square distortions. First, it uses the function with a partition consisting of length-one intervals. In the second trial, implements a µ-law compressor, quantiz quantizes the compressed data, and compand expands the quantized data. The output shows that the distortion is smaller for the second scheme. This is because equal-length intervals are well suited to the logarithm of sig, but not well suited to sig.

The figure shows how the compander changes sig. Mu = 255;% Parameter for mu-law compander sig = -4.1:4; sig = exp(sig);% Exponential signal to quantize V = max(sig);% 1. Quantize using equal-length intervals and no compander. [index,quants,distor] = quantiz(sig,0:floor(V),0:ceil(V));% 2. Use same partition and codebook, but compress% before quantizing and expand afterwards. Compsig = compand(sig,Mu,V, 'mu/compressor'); [index,quants] = quantiz(compsig,0:floor(V),0:ceil(V)); newsig = compand(quants,Mu,max(quants), 'mu/expander'); distor2 = sum((newsig-sig).^2)/length(sig); [distor, distor2]% Display both mean square distortions.

Plot(sig);% Plot original signal. Hold on; plot(compsig,'r--');% Plot companded signal. Legend('Original','Companded','Location','NorthWest') The output and figure are below. Note For long sequences from sources having skewed distributions and small alphabets, arithmetic coding compresses better than Huffman coding.

To learn how to use arithmetic coding, see. Create a Huffman Code Dictionary in MATLAB Huffman coding requires statistical information about the source of the data being encoded. In particular, the p input argument in the huffmandict function lists the probability with which the source produces each symbol in its alphabet. For example, consider a data source that produces 1s with probability 0.1, 2s with probability 0.1, and 3s with probability 0.8. The main computational step in encoding data from this source using a Huffman code is to create a dictionary that associates each data symbol with a codeword.

The commands below create such a dictionary and then show the codeword vector associated with a particular value from the data source. Sig = repmat([3 3 1 3 3 3 3 3 2 3],1,50);% Data to encode symbols = [1 2 3];% Distinct data symbols appearing in sig p = [0.1 0.1 0.8];% Probability of each data symbol dict = huffmandict(symbols,p);% Create the dictionary. Hcode = huffmanenco(sig,dict);% Encode the data. Dhsig = huffmandeco(hcode,dict);% Decode the code. Arithmetic Coding • • • Section Overview Arithmetic coding offers a way to compress data and can be useful for data sources having a small alphabet. The length of an arithmetic code, instead of being fixed relative to the number of symbols being encoded, depends on the statistical frequency with which the source produces each symbol from its alphabet. For long sequences from sources having skewed distributions and small alphabets, arithmetic coding compresses better than Huffman coding.

The arithenco and arithdeco functions support arithmetic coding and decoding. Represent Arithmetic Coding Parameters Arithmetic coding requires statistical information about the source of the data being encoded. In particular, the counts input argument in the arithenco and arithdeco functions lists the frequency with which the source produces each symbol in its alphabet. You can determine the frequencies by studying a set of test data from the source. The set of test data can have any size you choose, as long as each symbol in the alphabet has a nonzero frequency. For example, before encoding data from a source that produces 10 x's, 10 y's, and 80 z's in a typical 100-symbol set of test data, define. Quantized = Columns 1 through 6 -1. Dragon Quest 4 Iso Joint. 0000 -1.0000 -1.0000 -1.0000 0.5000 0.5000 Columns 7 through 12 2.0000 2.0000 2.0000 2.0000 2.0000 3.0000 Column 13 3.0000 Scalar Quantization Example 2 This example illustrates the nature of scalar quantization more clearly.

After quantizing a sampled sine wave, it plots the original and quantized signals. The plot contrasts the x's that make up the sine curve with the dots that make up the quantized signal. The vertical coordinate of each dot is a value in the vector codebook.

Quantization Represent Partitions Scalar quantization is a process that maps all inputs within a specified range to a common value. This process 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 and a. A quantization partition defines several contiguous, nonoverlapping ranges of values within the set of real numbers. To specify a partition in the MATLAB ® environment, list the distinct endpoints of the different ranges in a vector.

For example, if the partition separates the real number line into the four sets. Codebook = [-1, 0.5, 2, 3]; is one possible codebook for the partition [0,1,3]. Determine Which Interval Each Input Is In The quantiz function also returns a vector that tells which interval each input is in. For example, the output below says 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. Partition = [3,4,5,6,7,8,9]; codebook = [3,3,4,5,6,7,8,9]; [index,quants] = quantiz([2 9 8],partition,codebook); Optimize Quantization Parameters • • Section Overview Quantization distorts a signal. You can reduce distortion by choosing appropriate partition and codebook parameters. However, testing and selecting parameters for large signal sets with a fine quantization scheme can be tedious. One way to produce partition and codebook parameters easily is to optimize them according to a set of so-called training data. Note The training data you use should be typical of the kinds of signals you will actually be quantizing.

Example: Optimizing Quantization Parameters The lloyds function optimizes the partition and codebook according to the Lloyd algorithm. The code below optimizes the partition and codebook for one period of a sinusoidal signal, starting from a rough initial guess. Then it uses these parameters to quantize the original signal using the initial guess parameters as well as the optimized parameters.

The output shows that the mean square distortion after quantizing is much less for the optimized parameters. The quantiz function automatically computes the mean square distortion and returns it as the third output parameter. Quantized = Columns 1 through 6 -1.0000 -1.0000 -1.0000 -1.0000 0.5000 0.5000 Columns 7 through 12 2.0000 2.0000 2.0000 2.0000 2.0000 3.0000 Column 13 3.0000 Scalar Quantization Example 2 This example illustrates the nature of scalar quantization more clearly. After quantizing a sampled sine wave, it plots the original and quantized signals. Free Download Program Dellorto Vhst Manual Transmission. The plot contrasts the x's that make up the sine curve with the dots that make up the quantized signal. The vertical coordinate of each dot is a value in the vector codebook.