2014年3月5日星期三

Non-uniform quantization

The next step after the voice is non-uniform quantization. The basic ideal of this quantization is coarsely quantize the large input and finely quantize the smaller input as ear is less sensitive to change at higher amplitude. 

This is the plot of the data sampled by the recorder:

In order to compare non-uniform quantization with uniform one, first we applied uniform quantization to the signal:


From the picture above we can see that the shape of the wave generally kept.

Then we applied nonuniform quantization:




The picture above shows the result of Mu quantization. The shape this really different from the original data. However, there is nothing wrong here. Nonuniform quantization, different from uniform quantization, need an extra step, that is expansion. The expanded data are showed in the picture below and this time it looks much more like the original data.





The picture below shows the distortion of the two quantization method. The latter one represent the nonuniform quantization's distortion. We can see that the non-uniform one will have a less distortion.



11






2014年3月4日星期二

Testing for infinite precision arithmetic coding

The arithmetic coding was finished recently and this blog is to show the testing of the code.

Since the algorithm of the code was assumed to be infinite precision which means the computer may be out of order if the input is too large, some short inputs were applied as examples to show the correctness of the codes.

1.    For the first example, the inputs are as follow:

A= [0 1 2]; ‘A’ gives the voltages of the voice signal given by the dictionary.
          P= [0.2 0.4 0.4]; ‘P’ gives the probabilities corresponds to the values in A.
          in= [2 1 0]; ‘in’ is input needs to be encoded.
          code=[1 0 1 1 0 0]; ‘code’ is the input to be decoded.


Encoder
The function of encoder is defined as:




And the result was showed as an array with the inputs:







The output [1 0 1 1 0 0] is the binary code for ‘210’ and to be transmitted.



Decoder
The function of decoder is defined as:


And the result was showed as an array with the inputs:






The input of the encoder is identical to the output of the decoder which means the encoder and decoder worked well and matches with each other.



2.    For the second example, the inputs are:

A= [0 1 2 3]; ‘A’ gives the voltages of the voice signal given by the dictionary.
          P= [0.05 0.05 0.5 0.4]; ‘P’ gives the probabilities corresponds to the values in A.
          in= [2 3 2 0]; ‘in’ is input needs to be encoded.
         code=[0 1 1 0 1 1 0 0 0]; ‘code’ is the input to be decoded.


Encoder

And the result was showed as an array with the inputs:






The output [0 1 1 0 1 1 0 0 0] is the binary code for ‘2320’ and to be transmitted.

Decoder
And the result was showed as an array with the inputs:








The input of the encoder is identical to the output of the decoder which means the encoder and decoder worked well and matches with each other.


After the testing of the two examples, the functions of the codes are proved to be correct. However, infinite precision arithmetic coding can only be applied with short input. consequently, it is not able to solve practical problems.