JPG picture compresion 1
Terminology JFIF = JPEF File Interchange Format JFIF Variants 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) 2
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 3
Color Model Changing User input User input Original Picture RGB True Color] Color model Changing] Subsampling User input Discrete Cosine Transformation (DCT) Quantisation User input Huffman Encoding Picture in JFIF Format 4
Color Model Changing Brightness 5
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) 6
Color Model Changing User input User input Original Picture RGB True Color] Color model Changing] Subsampling User input Discrete Cosine Transformation (DCT) Quantisation User input Huffman Encoding Picture in JFIF Format 7
Subsampling Cb,Cr Compresion Ratio 67% 2 pixels subsampling Y1 Cb1Cr1 6 Bytes Y1 Y2 ØCb ØCr 4 Bytes Compresion Ratio 67% 8
Subsampling Cb,Cr Compresion Ratio 50% 4 pixels subsampling Y1 Cb1Cr1 12 Bytes Y3 Cb3Cr3 Y4 Cb4Cr4 Y1 Y2 Y3 Y4 ØCb ØCr 6 Bytes Compresion Ratio 50% 9
Color Model Changing User input User input Original Picture RGB True Color] Color model Changing] Subsampling User input Discrete Cosine Transformation (DCT) Quantisation User input Huffman Encoding Picture in JFIF Format 10
DCT transformation where for for
DCT Pro 8x8 pixels block 12
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 13
DCT Coeficients AC coeficient (= 8 times average brightness) 14
Quantisation User input User input Original Picture RGB True Color] Color model Changing] Subsampling User input Discrete Cosine Transformation (DCT) Quantisation User input Huffman Encoding Picture in JFIF Format 15
Quantisation Matrix (Brightnes, 90% quality) 16
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.
Quantisation Coeficients 18
AC coeficients Stored separately No comprimation Possible use for a quick picture prewiew
Quantisation User input User input Original Picture RGB True Color] Color model Changing] Subsampling User input Discrete Cosine Transformation (DCT) Quantisation User input Huffman Encoding Picture in JFIF Format 20
Huffmanov encoding + Run Lenghth Encoding 21
Example 0, -2, -1, -1, -1, 0, 0, -1, -1
Quantisation User input User input Original Picture RGB True Color] Color model Changing] Subsampling User input Discrete Cosine Transformation (DCT) Quantisation User input Huffman Encoding Picture in JFIF Format 23
Reconstructed DCT coefficients table
Inverse DCT
Differencies