I am learning vector quantization in terms of image compression and reconstruction, I was wondering why do we form an initial codebook from the training set? Since we are transmitting the index of the codeword only, then why wouldn't we just treat the training set as the final codebook. This would result in more accurate reconstruction, right? What would be the difference?
1 Answers
The codebook is not an image to be transmitted. The codeword is a reference point to a row in a k-dimensional codebook. Note: a codebook is essentially a 2D array where the row number is the codeword.
Example: 1000 training images are of size 512x512 each. If we want to create a codebook sized 256, to compress a 512x512 image into a 128x128 VQ (Vector Quantized) Index table, then our codebook needs 16 dimensions (i.e., each 4x4 block (16 values) in our original image is compressed into 1 value which is a codeword). Whichever clustering algorithm (eg. LBG) you use, will find the closest 16 values which best represent a 4x4 block in the 1000 training images. These 16 values will be put into the codebook. After the best 256 groups or clusters of 16 values are found, the codebook is ready for use.
This codebook needs to be sent to the receiver once. It is a 256 row, 16-dimensional structure, compared to 1000 512x512 training images. You send a 128x128 index table to the receiver who can then lookup the location in the codebook and rebuild the 512x512 image. It will not be exact, as this type of compression is lossy.