IT++ Logo Newcom Logo

itpp::Vector_Quantizer Class Reference
[Source Coding Routines]

Class for vector quantization. More...

#include <itpp/srccode/vq.h>

List of all members.

Public Member Functions

 Vector_Quantizer ()
 Default constructor.
 Vector_Quantizer (const char *Name)
 Create a VQ from a VQ file.
int encode (const vec &x)
 Encode the input vector.
ivec encode (const vec &x, int num)
 Encode the input vector, and return the num best indices.
vec decode (int Index) const
 Decode the index.
Array< vecdecode (const ivec &Index) const
 Decode the indices.
vec Q (const vec &x)
 Quantize the input vector.
vec operator() (const vec &x)
 Quantize the input vector.
void set_codebook (const mat &CB)
 Initialize the codebook by a matrix.
mat get_codebook () const
 Returns the codebook.
void set_codevector (int Index, const vec &indata)
 Set a codevector in the codebook.
vec get_codevector (int Index) const
 Returns the codevector at the given index.
void modify_codevector (int no, double mul, const vec &add)
 Rescale and translate a codevector.
int size () const
 Returns the size (number of codevectors) of the VQ.
int dim () const
 Returns the dimension of the VQ.
int nobits () const
 Returns the number of bits of the VQ [log2(size)/dim].
void load (const char *Name)
 Load the codebook from a file.
void save (const char *Name) const
 Save the codebook to a file.
double latest_distortion ()
 Returns the distortion at the latest time a vector was encoded.

Protected Attributes

vec CodeBook
 The vector containing the code book.
int Size
 The size and dimension of the code book respectively.
int Dim
double LatestDist
 The distortion at the latest time a vector was encoded.


Detailed Description

Class for vector quantization.

The following code illustrates how the VQ can be initialized from a file and used to quantize a random vector.

Vector_Quantizer        Quantizer;
vec                                     x,y;
int                                     i;

Quantizer.load("randomvq.vq");
x=randn(Quantizer.dim());
i=Quantizer.encode(x);
y=Quantizer.decode(i);

Definition at line 65 of file vq.h.


Constructor & Destructor Documentation

itpp::Vector_Quantizer::Vector_Quantizer  ) 
 

Default constructor.

Definition at line 51 of file vq.cpp.

References Dim, LatestDist, and Size.

itpp::Vector_Quantizer::Vector_Quantizer const char *  Name  ) 
 

Create a VQ from a VQ file.

Definition at line 58 of file vq.cpp.

References Dim, LatestDist, load(), and Size.


Member Function Documentation

int itpp::Vector_Quantizer::encode const vec x  ) 
 

Encode the input vector.

Definition at line 67 of file vq.cpp.

References CodeBook, Dim, and Size.

Referenced by Q().

ivec itpp::Vector_Quantizer::encode const vec x,
int  num
 

Encode the input vector, and return the num best indices.

Definition at line 90 of file vq.cpp.

References CodeBook, Dim, and Size.

vec itpp::Vector_Quantizer::decode int  Index  )  const [inline]
 

Decode the index.

Definition at line 130 of file vq.h.

References get_codevector().

Referenced by Q().

Array< vec > itpp::Vector_Quantizer::decode const ivec Index  )  const
 

Decode the indices.

Definition at line 119 of file vq.cpp.

References get_codevector().

vec itpp::Vector_Quantizer::Q const vec x  )  [inline]
 

Quantize the input vector.

Definition at line 131 of file vq.h.

References decode(), and encode().

Referenced by operator()().

vec itpp::Vector_Quantizer::operator() const vec x  )  [inline]
 

Quantize the input vector.

Definition at line 132 of file vq.h.

References Q().

void itpp::Vector_Quantizer::set_codebook const mat CB  ) 
 

Initialize the codebook by a matrix.

Definition at line 242 of file vq.cpp.

References CodeBook, itpp::Mat< Num_T >::cols(), Dim, itpp::Mat< Num_T >::rows(), and Size.

mat itpp::Vector_Quantizer::get_codebook  )  const
 

Returns the codebook.

Definition at line 254 of file vq.cpp.

References CodeBook, Dim, and Size.

void itpp::Vector_Quantizer::set_codevector int  Index,
const vec indata
 

Set a codevector in the codebook.

Definition at line 234 of file vq.cpp.

References CodeBook, it_error_if, and itpp::length().

vec itpp::Vector_Quantizer::get_codevector int  Index  )  const
 

Returns the codevector at the given index.

Definition at line 229 of file vq.cpp.

References CodeBook.

Referenced by decode().

void itpp::Vector_Quantizer::modify_codevector int  no,
double  mul,
const vec add
 

Rescale and translate a codevector.

Definition at line 219 of file vq.cpp.

References CodeBook.

int itpp::Vector_Quantizer::size  )  const [inline]
 

Returns the size (number of codevectors) of the VQ.

Definition at line 126 of file vq.h.

References Size.

int itpp::Vector_Quantizer::dim  )  const [inline]
 

Returns the dimension of the VQ.

Definition at line 128 of file vq.h.

References Dim.

int itpp::Vector_Quantizer::nobits  )  const [inline]
 

Returns the number of bits of the VQ [log2(size)/dim].

Definition at line 127 of file vq.h.

References itpp::levels2bits(), and Size.

void itpp::Vector_Quantizer::load const char *  Name  ) 
 

Load the codebook from a file.

Parameters:
Name The name of the VQ file
The file format is a textfile where each row is a vector from the codebook.

Definition at line 177 of file vq.cpp.

References it_error_if, and itpp::length().

Referenced by Vector_Quantizer().

void itpp::Vector_Quantizer::save const char *  Name  )  const
 

Save the codebook to a file.

Parameters:
Name The name of the VQ file
The file format is a textfile where each row is a vector from the codebook.

Definition at line 203 of file vq.cpp.

References CodeBook, itpp::Vec< Num_T >::length(), and Size.

double itpp::Vector_Quantizer::latest_distortion  )  [inline]
 

Returns the distortion at the latest time a vector was encoded.

Definition at line 129 of file vq.h.

References LatestDist.


Member Data Documentation

vec itpp::Vector_Quantizer::CodeBook [protected]
 

The vector containing the code book.

Definition at line 117 of file vq.h.

Referenced by encode(), get_codebook(), get_codevector(), modify_codevector(), save(), set_codebook(), and set_codevector().

int itpp::Vector_Quantizer::Size [protected]
 

The size and dimension of the code book respectively.

Definition at line 119 of file vq.h.

Referenced by encode(), get_codebook(), nobits(), save(), set_codebook(), size(), and Vector_Quantizer().

double itpp::Vector_Quantizer::LatestDist [protected]
 

The distortion at the latest time a vector was encoded.

Definition at line 121 of file vq.h.

Referenced by latest_distortion(), and Vector_Quantizer().


The documentation for this class was generated from the following files:
SourceForge Logo

Generated on Thu Apr 19 14:20:43 2007 for IT++ by Doxygen 1.4.6