ocvolume.vq
Class codebook

java.lang.Object
  |
  +--ocvolume.vq.codebook

public class codebook
extends java.lang.Object

last updated on June 15, 2002
description: codebook for Vector Quantization component
calls: centroid, point
called by: volume, train
input: speech signal
output: set of centroids, set of indices


Field Summary
protected  centroid[] centroids
          centroids array
protected  int codebook_size
          codebook size - number of codewords (codevectors)
default is: 256
protected  int dimension
          dimension
protected  double MIN_DISTORTION
          minimum distortion
protected  point[] pt
          training points
protected  double SPLIT
          split factor (should be in the range of 0.01 <= SPLIT <= 0.05)
 
Constructor Summary
codebook(point[] tmpPt)
          constructor to train a codebook with given training points and default codebook size (256)
calls: none
called by: trainCodebook
codebook(point[] tmpPt, int size)
          constructor to train a codebook with given training points and codebook size
calls: none
called by: trainCodebook
codebook(java.sql.ResultSet rs, int d, int cbk_size)
          constructor to load a codebook from a Result Set
calls: centroid
called by: volume
codebook(java.lang.String inputFile)
          constructor to load a saved codebook from external file
calls: centroid
called by: volume
 
Method Summary
 double getDistortion(point[] pts)
          calculates the distortion
calls: none
called by: volume
protected  void initialize()
          creates a codebook using LBG algorithm which includes K-means
calls: centroid
called by: codebook
 int[] quantize(point[] pts)
          quantize the input array of points in k-dimensional space
calls: none
called by: volume
 void saveToDB(java.lang.String word)
          save codebook to database
calls: database
called by: train
 void saveToFile(java.lang.String filepath)
          save codebook to txt file
calls: none
called by: train
protected  void split()
          splitting algorithm to increase number of centroids by multiple of 2
calls: centroid
called by: codebook
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPLIT

protected final double SPLIT
split factor (should be in the range of 0.01 <= SPLIT <= 0.05)

See Also:
Constant Field Values

MIN_DISTORTION

protected final double MIN_DISTORTION
minimum distortion

See Also:
Constant Field Values

codebook_size

protected int codebook_size
codebook size - number of codewords (codevectors)
default is: 256


centroids

protected centroid[] centroids
centroids array


pt

protected point[] pt
training points


dimension

protected int dimension
dimension

Constructor Detail

codebook

public codebook(point[] tmpPt,
                int size)
constructor to train a codebook with given training points and codebook size
calls: none
called by: trainCodebook

Parameters:
tmpPt - training vectors
size - codebook size

codebook

public codebook(point[] tmpPt)
constructor to train a codebook with given training points and default codebook size (256)
calls: none
called by: trainCodebook

Parameters:
tmpPt - training vectors

codebook

public codebook(java.sql.ResultSet rs,
                int d,
                int cbk_size)
constructor to load a codebook from a Result Set
calls: centroid
called by: volume

Parameters:
rs - the Result Set from database
d - dimension of the points in the codebook
cbk_size - size of codebook

codebook

public codebook(java.lang.String inputFile)
constructor to load a saved codebook from external file
calls: centroid
called by: volume

Parameters:
inputFile - file location
Method Detail

initialize

protected void initialize()
creates a codebook using LBG algorithm which includes K-means
calls: centroid
called by: codebook


saveToDB

public void saveToDB(java.lang.String word)
save codebook to database
calls: database
called by: train

Parameters:
word - word that the codebook is trained for

saveToFile

public void saveToFile(java.lang.String filepath)
save codebook to txt file
calls: none
called by: train

Parameters:
filepath - external file path

split

protected void split()
splitting algorithm to increase number of centroids by multiple of 2
calls: centroid
called by: codebook


quantize

public int[] quantize(point[] pts)
quantize the input array of points in k-dimensional space
calls: none
called by: volume

Parameters:
pts - points to be quantized
Returns:
quantized index array

getDistortion

public double getDistortion(point[] pts)
calculates the distortion
calls: none
called by: volume

Parameters:
pts - points to calculate the distortion with
Returns:
distortion measure