260 likes | 268 Views
Learn about the JPG compression terminology, sequential and progressive storing, color model changing, subsampling, discrete cosine transformation, quantization, Huffman encoding, compression ratios, DCT coefficients, quantization matrices, and encoding techniques.
E N D
Terminology • JPG, JPEG = Join Photograph Expert Group • JFIF = JPEF File Interchange Format • JFIF Variants • Sequential, most used JPG • Progressive – for network transmiting • Lossles • Hierarchical – more resolution in one file (similar to format TIFF)
Sequential JPG storing process Original Picture RGB True Color] Color model Changing] Subsampling User input Discrete Cosine Transformation (DCT) Quantisation User input Huffman Encoding Picture in JFIF Format
Color Model Changing Original Picture RGB True Color] Color model Changing] Subsampling User input Discrete Cosine Transformation (DCT) Quantisation User input Huffman Encoding Picture in JFIF Format
Color Model Changing Brightness
Color Model Transformation 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 + 128 Cr = 0,5*R - 0,4187*G - 0,0813*B + 128 R = Y + 1.402*(Cr-128) G = Y - 0.34414*(Cb-128) - 0.71414*(Cr-128) B = Y + 1.772*(Cb-128)
Color Model Changing Original Picture RGB True Color] Color model Changing] Subsampling User input Discrete Cosine Transformation (DCT) Quantisation User input Huffman Encoding Picture in JFIF Format
Subsampling Cb,Cr 2 pixels subsampling Y1 Cb1Cr1 Y2 Cb2Cr2 6 Bytes Y1 Y2 ØCb ØCr 4 Bytes Compresion Ratio 67%
Subsampling Cb,Cr 4 pixels subsampling Y1 Cb1Cr1 Y2 Cb2Cr2 12 Bytes Y3 Cb3Cr3 Y4 Cb4Cr4 Y1 Y2 Y3 Y4 ØCb ØCr 6 Bytes Compresion Ratio 50%
Color Model Changing Original Picture RGB True Color] Color model Changing] Subsampling User input Discrete Cosine Transformation (DCT) Quantisation User input Huffman Encoding Picture in JFIF Format
DCT transformation where for for
DCT Pro 8x8 pixels block
Example 139 144 149 153 155 155 155 155 144 151 153 156 159 156 156 156 150 155 160 163 158 156 156 156 159 161 162 160 160 159 159 159 159 160 161 162 162 155 155 155 161 161 161 161 160 157 157 157 162 162 161 163 162 157 157 157 162 162 161 161 163 158 158 158
DCT Coeficients AC coeficient (= 8 times average brightness)
Quantisation Original Picture RGB True Color] Color model Changing] Subsampling User input Discrete Cosine Transformation (DCT) Quantisation User input Huffman Encoding Picture in JFIF Format
Quantisation Matrices • . Defined by JPEG . For Brightness, for Cb, for Cr • Defined for (so called) quality 10% and 90%. • For quality values between 10% and 90% linear interpolation is used • For quality values under 10% or above 90% linear extrapolation can me mathematicaly used, but it is not recomanded by JPEG.
AC coeficients • Stored separately • No comprimation • Possible use for a quick picture prewiew
Quantisation Original Picture RGB True Color] Color model Changing] Subsampling User input Discrete Cosine Transformation (DCT) Quantisation User input Huffman Encoding Picture in JFIF Format
Huffmanov encoding + Run Lenghth Encoding
Example 0, -2, -1, -1, -1, 0, 0, -1, -1
Quantisation Original Picture RGB True Color] Color model Changing] Subsampling User input Discrete Cosine Transformation (DCT) Quantisation User input Huffman Encoding Picture in JFIF Format