#include <itpp/srccode/vq.h>
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< vec > | decode (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 |
The size and dimension of the code book respectively. | |
double | LatestDist |
The distortion at the latest time a vector was encoded. |
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.
|
Default constructor.
Definition at line 52 of file vq.cpp. References Dim, LatestDist, and Size. |
|
Create a VQ from a VQ file.
Definition at line 59 of file vq.cpp. References Dim, LatestDist, load(), and Size. |
|
Encode the input vector.
Definition at line 68 of file vq.cpp. References itpp::Vec< Num_T >::_elem(), CodeBook, and LatestDist. Referenced by Q(). |
|
Encode the input vector, and return the num best indices.
Definition at line 91 of file vq.cpp. References itpp::Vec< Num_T >::_elem(), itpp::Vec< Num_T >::clear(), CodeBook, LatestDist, and itpp::Vec< Num_T >::length(). |
|
Decode the index.
Definition at line 130 of file vq.h. References get_codevector(). Referenced by Q(). |
|
Decode the indices.
Definition at line 120 of file vq.cpp. References get_codevector(), and itpp::Vec< Num_T >::length(). |
|
Quantize the input vector.
Definition at line 131 of file vq.h. References decode(), and encode(). Referenced by operator()(). |
|
Quantize the input vector.
Definition at line 132 of file vq.h. References Q(). |
|
Initialize the codebook by a matrix.
Definition at line 243 of file vq.cpp. References CodeBook, itpp::Mat< Num_T >::cols(), Dim, itpp::Mat< Num_T >::rows(), itpp::Vec< Num_T >::set_length(), and Size. |
|
Returns the codebook.
|
|
Set a codevector in the codebook.
Definition at line 235 of file vq.cpp. References itpp::Vec< Num_T >::_elem(), CodeBook, Dim, it_error_if, and itpp::length(). |
|
Returns the codevector at the given index.
Definition at line 230 of file vq.cpp. References CodeBook, Dim, and itpp::Vec< Num_T >::mid(). Referenced by decode(). |
|
Rescale and translate a codevector.
Definition at line 220 of file vq.cpp. References itpp::Vec< Num_T >::_elem(), CodeBook, and Dim. |
|
Returns the size (number of codevectors) of the VQ.
Definition at line 126 of file vq.h. Referenced by load(). |
|
Returns the dimension of the VQ.
Definition at line 128 of file vq.h. Referenced by load(). |
|
Returns the number of bits of the VQ [log2(size)/dim].
Definition at line 127 of file vq.h. References itpp::levels2bits(), and Size. |
|
Load the codebook from a file.
Definition at line 178 of file vq.cpp. References CodeBook, dim(), Dim, it_error_if, itpp::Vec< Num_T >::length(), itpp::length(), itpp::Vec< Num_T >::replace_mid(), itpp::Vec< Num_T >::set_length(), size(), and Size. Referenced by Vector_Quantizer(). |
|
Save the codebook to a file.
Definition at line 204 of file vq.cpp. References CodeBook, Dim, itpp::Vec< Num_T >::length(), and itpp::Vec< Num_T >::mid(). |
|
Returns the distortion at the latest time a vector was encoded.
|
|
The vector containing the code book.
Definition at line 117 of file vq.h. Referenced by encode(), get_codebook(), get_codevector(), load(), modify_codevector(), save(), set_codebook(), and set_codevector(). |
|
The size and dimension of the code book respectively.
Definition at line 119 of file vq.h. Referenced by get_codebook(), load(), nobits(), set_codebook(), and Vector_Quantizer(). |
|
The size and dimension of the code book respectively.
Definition at line 119 of file vq.h. Referenced by get_codebook(), get_codevector(), load(), modify_codevector(), save(), set_codebook(), set_codevector(), and Vector_Quantizer(). |
|
The distortion at the latest time a vector was encoded.
Definition at line 121 of file vq.h. Referenced by encode(), and Vector_Quantizer(). |
Generated on Fri Jan 11 08:51:43 2008 for IT++ by Doxygen 1.3.9.1