Data compression
lossless – looking for unicolor areas or repeating patterns –Run length encoding –Dictionary compressions Lossy – reduction of colors - approximating methods (JPEG)
Grid graphics formats BMP – no compression PCX – lossless compression RLE PNG – lossless dictionary compression LZW GIF – lossless dictionary compression LZW + reduction to 256 color (adaptive palette) JPG – approximating compression JPEG
JFIF format (JPEG File Interchange format) sequential, common known progressive, more effective, for computer net transmissions lossless, not known and not widely supported hierarchic, more resolutions in one file, quick preview
Sequential JFIF encoding
Color model transofmation RGB → Y Cb Cr Y= 0,299*R + 0,587*G + 0,114*B (brightness) Cb = - 0,1687*R - 0,3313*G + 0,5*B Cr = 0,5*R - 0,4187*G - 0,0813*B R = Y *(Cr-128) G = Y *(Cb-128) *(Cr-128) B = Y *(Cb-128)
Subsampling of Cb,Cr Computing of average value for the block 2x1 pixels (6 bits sample), –6 bits -> 4 bits (compression 67%) or 2x2 pixels (12 bits sample), –12 bits -> 6 bits (compression 50%)
DCT transformation
Example
DCT coefficients AC coefficient (= 8 x average brightness
Quantization matrix – example for 90% “qality”
Quantization matrices Defined by standardization committee JPEG. Separately for brightness and for color components. Defined matrices for quality 10% and 90%. For other values of quality between 10% and 90%obtained by linear interpolation. For values under 10% or over 90% extrapolation can be used but it is not recommended.
Coefficients after quantisation
AC coefficients Stored separately Not compressed Possibility used for quick preview
Huffman encoding
Example 0, -2, -1, -1, -1, 0, 0, -1, -1, 0, 0, 0…..
Reconstruction of DCT coeffients
After inverse DCT transformation
Table of differences