This is a very simple compressed image format that I designed in 2003 as part of my Vision 1.0 project. PTCX features a basic adaptive quantization scheme that is reasonably effective for low frequency texture information (e.g. grass and gravel), and supports a wide variety of pixel formats.
Check out this blog post for information about the performance of PTCX.
PTCX closely resembles the DirectX Texture Compression (DXT or S3TC) formats, but offers significantly greater flexibility. This format divides a source image into macroblock tiles and then independently and linearly quantizes each block using an adaptive vector quantizer.
What makes PTCX unique is that the block size, quantization step size, control value precision, and range evaluation functions are all fully configurable and adjust according to the characteristics of the input data.
PTCX quantizes images in units of pixels known as macroblocks. The size of a macroblock is configurable but is set to 16x16 by default. For large images with very low frequency data, higher macroblock sizes may provide greater compression rates without introducing an unacceptable level of distortion. In most cases however, 16x16 seems to offer the best trade off between quality and size.
Once a macroblock is selected, PTCX analyzes the pixel data in order to decide whether to process the block as a whole or divide it up into a series of smaller microblocks to better preserve information. This is accomplished in conjunction with the selection of a range evaluation function that generates control values to tightly fit the pixel range of the block.
The goal of this process is to maximize compression efficiency while minimizing distortion. In most cases these objectives are mutually exclusive, so we rely upon a simple scoring metric. For each microblock configuration we measure the mean squared quantization error. We then select the configuration whose error is closest to a threshold without overflow. Our threshold is simply defined as the maximum permissible error based on human perception.
The process of quantizing an image block is responsible for producing a pair of control vectors and a quantization table. The control vectors specify the endpoints of the linear quantization space (within 3-space) while the quantization table indicates, for each pixel, a percentage based location within this space.
Like all quantizers, the number of bits we use for each entry in the quantization table and for our control vectors has a big impact on the resolution of reconstructed values, and thus our quantization error. During encode, PTCX examines the input image format as well as a user supplied quality parameter in order to derive the precision of these quantization settings.
There is another factor that also plays an important role in determining our overall quantization quality: the range of our control vectors. These values should be selected in a manner that minimizes the block quantization error, which is highly dependent upon the pixel data. PTCX uses the following three methods for computing control vectors and selects the best one for each block.
This method independently selects the maximum and minimum values along each axis. This method is guaranteed to fully enclose all pixels in the source block, but may lead to significant wasted range. Min-Max is usually selected when the data is highly uncorrelated and is not dominated by any axis.
This method selects the maximum and minimum pixel values. This method ensures that the control values are found in the source data and is usually selected when the data is dominated by one or two particular values.
Linear Least Squares:
This method uses a line fitting approach to derive control values that fit the source data and is particularly useful when the data is segmented.
One final area where PTCX diverges from the design of S3TC is that it does not (yet) take advantage of control value ordering. In S3TC, the quantization step size changes based on whether the first control value is greater or smaller than the second value. For example, in S3TC if the first value is larger, then the step increments may be defined roughly as 0, 0.33, 0.66, and 1.0. Alternatively, if the first value is smaller, then the steps could be 0.0, 0.5, 1.0. PTCX may support this scheme in the future, but for now it simply places the smaller value first in the stream.
The most noticable feature lacking from PTCX, which significantly reduces its practical real world utility, is hardware support. Unlike the similar DXT and S3TC formats, PTCX must be expanded to raw values in order to be rendered by a GPU, which makes it an inferior format in most circumstances.
Nevertheless, PTCX continues to serve as a useful learning aid, and may also be used in scenarios where a fast and lightweight image compressor is needed with an image format that is not supported by existing image codecs.