Class for vector quantization.
More...
#include <itpp/srccode/vq.h>
|
| 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.
|
|
|
vec | CodeBook |
| The vector containing the code book.
|
|
int | Size |
| The size of the code book.
|
|
int | Dim |
| The dimension of the code book.
|
|
double | LatestDist |
| The distortion at the latest time a vector was encoded.
|
|
Class for vector quantization.
The following code illustrates how the VQ can be initialized from a file and used to quantize a random vector.
vec x,y;
int i;
Quantizer.
load(
"randomvq.vq");
Class for vector quantization.
int dim() const
Returns the dimension of the VQ.
vec decode(int Index) const
Decode the index.
int encode(const vec &x)
Encode the input vector.
void load(const char *Name)
Load the codebook from a file.
double randn(void)
Generates a random Gaussian (0,1) variable.
Definition at line 62 of file vq.h.
◆ decode()
vec itpp::Vector_Quantizer::decode |
( |
int | Index | ) |
const |
|
inline |
◆ Q()
vec itpp::Vector_Quantizer::Q |
( |
const vec & | x | ) |
|
|
inline |
◆ operator()()
vec itpp::Vector_Quantizer::operator() |
( |
const vec & | x | ) |
|
|
inline |
Quantize the input vector.
Definition at line 132 of file vq.h.
References Q().
◆ size()
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.
◆ dim()
int itpp::Vector_Quantizer::dim |
( |
| ) |
const |
|
inline |
Returns the dimension of the VQ.
Definition at line 128 of file vq.h.
References Dim.
◆ nobits()
int itpp::Vector_Quantizer::nobits |
( |
| ) |
const |
|
inline |
◆ load()
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.
◆ save()
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.
◆ latest_distortion()
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.
◆ CodeBook
vec itpp::Vector_Quantizer::CodeBook |
|
protected |
The vector containing the code book.
Definition at line 115 of file vq.h.
◆ Size
int itpp::Vector_Quantizer::Size |
|
protected |
◆ Dim
int itpp::Vector_Quantizer::Dim |
|
protected |
The dimension of the code book.
Definition at line 119 of file vq.h.
Referenced by dim().
◆ LatestDist
double itpp::Vector_Quantizer::LatestDist |
|
protected |
The documentation for this class was generated from the following file: