readme - ECE Users Pages

advertisement
User Manual
DISME : Matlab Distortion Measure Tool
This software tool is developed as a project in EE8873: Data Compression, Spring 2004.
It is aimed at providing easy-to-use MATLAB tool for computing many well-known
distortion measures used in data compression.
The software package can be divided into 2 modules: graphical user interface module and
the computation module. The graphical user interface is responsible for rendering the
easy-to-use interface so that the user’s interaction with the program can be done in a
convenient and efficient manner. The computational module is responsible for computing
the distortion measure requested by the user. This module is nicely hidden behind the gui
so the user actually doesn’t need to understand the matlab code or syntax in order to
operate the software tool. However, for those with more experience in matlab, the direct
interaction with this module from matlab command line may be desirable. That option is
also allowed along with the sufficient documentation to guide the user trough the process.
The sample files are also provided as part of the package.
GUI module

disme.m
-main gui

dlgopen.m
-open a file

closem.m
-close a figure

loadfile.m
-load two required inputs from file(s)

gethdr.m
-extract header information from file

comptool.m
-define functionality of the gui buttons
Computation module

distance.m
-main computation routine calculating all the distortion measures

distispf.m
-a sub-routine get invoked by distance.m to calculate the Itakura-
Saito distance (power spectrum based)

distskl.m
-a sub-routine to calculate the symmetric Kullback-Liebler distance.

autoc.m
-a sub-routine to calculate autocorrelation function given an input
sequence

ilpc.m
-a sub-routine to calculate the autocorrelation coefficients and linear
prediction coefficients based on the given input sequence and an LP order.
Sample Input Files

sx36.wav
-sample speech .wav file from TIMIT

sx44.wav
-sample speech .wav file from TIMIT

rand_sig.mat -random signal in .mat format

sine_sig.mat -sinusoid signal in .mat format
Running the software
1. Download the software tool, create a new directory name disme, then unzip and
extract the package into the directory. Let’s assume that directory has the
following path: C:/matlabR12/work/disme
2. Open matlab (required version 5.0 or above). Make matlab accessible to the
disme directory by typing adding a new path to this directory at a matlab prompt:
>> addpath(‘C:/matlabR12/work/disme’);
Now the user can access all the files and functions in the directory.
3. Now the program is ready to be run. There are two possible mode of operating:
a. GUI mode: run the gui by type at matlab promp:
>> disme
Simply follow the instructions which will describe to you what needs to be done
in order to start the gui. First the user chooses how the input is to be entered (i.e. from
file vs from matlab variable). Once the two valid inputs are entered the main gui
window will be launched. The gui window is quite self-explanatory.
The distortion measures are divided into two categories and placed on the left and
right column in the gui window: time-domain measures and the frequency-domain
measures. The user has the option to change the sampling frequency (default 10000 or
the rate read from file), the linear prediction order (default 14), the p order for Lpnorm distances (i.e. Lp distance and Log-Spectral distance, p can be any positive real
number. Default is p=2.). To do so, simply replace the old parameter value with a
new value directly in the value box.
Furthermore, the user has an option to compare the two sequences in a frame-byframe basis or compare the entire sequence at once (as a single frame). To do so, go to
the bottom of the gui window and select the button ‘per frame’ or ‘entire’, respectively.
Note that the frame size (number of samples in each frame) can be changed as desired by
directly change from the default values of 100 samples/frame to a desired value.
Some of the distance measures provide additional option. To select an option,
press that option button (e.g. ‘sym’ button for Itakura-Saito distance) then press the
corresponding distance button to calculate the distance again with the new option.
Here is the list of options available:
- Lp distance: can vary the order p (to be anything > 0, default p=2)
- Cluster distance: option of Mahalanobis weighting (default is no weighting)
- Weight-Ceptral distance: ramp (inverse variance) weighting (default) or raisedsine weighting
- Itakura-Saito distance based on power spectrum: select between symmetric and
traditional asymmetric measure (default)
- Itakura-Saito distance based on linear prediction: symmetric and asymmetric
option (default)
- Log-Spectral distance: can vary the order p (to be anything > 0, default p=2)
b. Command line mode: the user needs to invoke a routine call ‘distance.m’.
This function calculate the distortion measure directly from matlab command line.
The usage is as follows:
>> dst = distance(x,y,N,type,opt);
output:
dst = the numerical value of the distance
Inputs:
x = input sequence #1 as a row or a column vector
y = input sequence #2 as a row or a column vector
N = linear prediction order for LPC-based distance
the liftering width (truncation in cepstral domain) for cepstrum distances
opt = 'single' for running the entire file as a single frame (default: display plot).
= 'all' for running the file in frame-by-frame basis. (will not display plot)
(from command line, opt is simply a display flag as x and y treated as one frame)
type = the types of distance measures to be computed. Selected from
'lp'
- Lp-norm based distance the default p = 2, (in gui mode support for p>0)
'cep'
- Cepstrum
'cls'
- Cluster-to-cluster distances
'orthog' - Orthogonality measure
'wcep' - Weighted cepstrum by a raised sine or a ramp(default)
'snr'
- Signal to noise ratio
'IS'
- Itakura-Saito (power spectrum based)
'IS_lpc' - Itakura-Saito (lpc based)
'LR'
- Likelihood ratio
'LLR' - log-likelihood ratio
'LS'
- Log spectral distances (Lp-normed based default p=2) *
'SKL'
- Symmetric Kullback-Liebler distance *
Examples
>> x = rand(100, 1); % x as a segment of random values
>> n = 1:1:100;
>> T = 1/1000;
>> y = sin(2*pi*200*n*T); %y as a segment of a sinusoid

cepstral distance from first 14 coefficients. Display results in a plot.
>> d1 = distance(x, y, 20, 'cep', 'single');

Itakura-Saito distance between their 14-order LP spectrums. Do not plot the
results.
>> d2 = distance(x, y, 14, 'IS_lpc', 'all');

SNR between x (clean) and y (noisy) , note that argument N is not used but
required so can be any number
>> d3 = distance(x, y, 0.0233, 'snr', 'all');
The detail syntax and options for this routine is also available when type:
>> help distance
Input Formats
Currently the tool supports one dimensional signal, which include a sequence of real
number of any length. If the input sequences are of different lengths, the distance
measure is calculated between the sequences truncated to the smaller length. The
following input file formats are supported.
.wav formats, including Microsoft .wav and TIMIT .wav formats
.mat matlab file format. An example of how to create a .mat file is as follows
>> x = rand(100, 1);
>> save rand_sig x
%save vector x in a file rand_sig.mat
>> y = sin(2*pi*200*n*T);
>> save all_sig x y
% save x and y in all_sig.mat
Note: since .mat file do not have header, so the sampling rate of the signal
is default at 10kHz. However, the user can directly change the sampling rate
in the gui window.
matlab variables can be used as the input sequences. For example, x and y defined
above are valid inputs. If you use the gui mode, you can elect to choose two variable
names from matlab workspace as your input signals. If you use command line mode, you
need to create two input signals first before invoking the function ‘distance’ as the
loading from file option is not supported in that mode.
Output Formats
Gui mode: there is no output, only the displayed results in a plot is shown. The user can
save the plot in a normal way as .fig or export to other formats such as .eps, .tiff, .jpg or
.bmp files.
Command line mode: The numerical value of the distance is the output of each valid
‘distance’ routine. This number can be viewed directly in matlab and used as a normal
variable or it can be saved into .mat file as in the .mat file creation procedure described
above.
Distortion Measures
A Distortion measure or distance measure is a numerical quantity which tells the degree
of difference between two variables. If a measure is a metric, then it satisfies 4 properties:
- Nonnegativity
0  d ( x, y )  
d ( x, y )  0 iff x  y
- Zero
- Symmetry
d ( x, y )  d ( y , x )
- Triangle-Inequaltity
d ( x , y )  d ( y , z )  d ( x, z )
In compression, it is a measure of how ‘good’ the reconstructed signal compared to the
original signal. In many cases ‘good’ are interpreted differently. Some measures are
designed to extract the objective difference of the two signals, such as the Lp-distance
which measure the absolute numerical difference at order p. On the other hand, some
other measures may be designed to gauge subjective or perceptual difference between the
signals, such as the Itakura-Saito distance or the signal to noise ratio. Hence, there is a
great number of distortion measures developed for various purposes. This software tool
contains around 10 of the most widely used distance measures.
The distortion measures collected can be divided into two main categories: the timedomain distortion measures and the frequency-domain distortion measures. The timedomain measures which compare any two arbitrary input sequences, while the frequencydomain measure is based on the FFT-domain representation of the input sequences.
Time-domain distortion measures:
i.
signal –to-noise ratio (SNR)
ii.
Lp Distance
iii.
Cluster-to-cluster distance
iv.
Orthogonality distance
Frequency-domain distortion Measures
i.
Cepstrum Distance
ii.
Weight-Cepstrum Distance
iii.
Itakura-Saito Distance based on power spectrum
iv.
Itakura-Saito Distance based on LP spectrum
v.
Log-Spectral Distances
vi.
Likelihood Ratio
vii.
Log-likelihood Ratio
viii.
Symmetric-Kullback Liebler distance
For more detail description of the measures and references, please refer to disme.ppt
-Rungsun Munkong
Download