Download presentation
Presentation is loading. Please wait.
Published byKelly Dennis Modified over 8 years ago
1
1 Image Formats
2
2 Color representation An image = a collection of picture elements (pixels) Each pixel has a “color” Different types of pixels Binary (1 bit): black/white Grayscale (8 bits) Color (3 colors, 8 bits each): red, green, blue A 1024x768 image requires 1024x768X3 bytes
3
3 Compression: to lose or not to lose? Goal: reduce redundancy Send the same information using fewer bits Originally developed for fax transmission Send high quality documents in short calls Two basic strategies: Lossless: can reconstruct exactly Lossy: can’t reconstruct, but looks the same
4
4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Opportunity: Large regions of a single color are common Approach: Record # of consecutive pixels for each color An example of lossless encoding Uncompressed 0000000000000000000001111 11111111100000000000001111 111111111111111111 RLE Row 1, 21:0,13:1;13:0;22:1 LZW, etc. use algorithms in addition to RLE 01010101010101010101 Run length encoding
5
5 PGM (Portable Gray Map) Represents grayscale images P2 24 7 15 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 15 15 15 0 0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 15 0 0 3 3 3 0 0 0 7 7 7 0 0 0 11 11 11 0 0 0 15 15 15 15 0 0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 0 0 0 3 0 0 0 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6
6 PPM Represents Color Images P3 4 15 0 0 0 0 0 0 0 0 0 15 0 15 0 0 0 0 15 7 0 0 0 0 0 0 0 0 0 0 0 0 0 15 7 0 0 0 15 0 15 0 0 0 0 0 0 0 0 0
7
7 Palette selection Opportunity: 24 bits can represent 16 million colors No picture uses all 16 million colors Human eye does not see small differences Approach: Select a palette of 256 colors Indicate which palette entry to use for each pixel Look up each color in the palette
8
8 GIF (Graphics Interchange Format) Palette selection, then lossless compression Opportunity: Common colors are sent more often Approach: Use fewer bits to represent common colors. Example: 1Blue75%75x1= 7575x2=150 01White20%20x2= 4020x2= 40 001Red 5% 5x3= 15 5x2= 10 130 200
9
9 Fact about JPEG Compression JPEG stands for Joint Photographic Experts Group JPEG compression is used with.jpg and can be embedded in.tiff and.eps files. Used on 24-bit color files. Works well on photographic images. Although it is a lossy compression technique, it yields an excellent quality image with high compression rates.
10
10 7A.5 JPEG Compression The JPEG Compression Algorithm
11
11 The JPEG Compression Algorithm
12
12 Block Encoding original image DCT DC component AC components Quantize zigzag run-length code Huffman code 10011011100011...
13
13 The JPEG Compression Algorithm Row m Col n Time Domain
14
14 Row u Col v Frequency Domain The JPEG Compression Algorithm
15
15 Great, but we still need to represent these values digitally Big numbers are localized to a small part of the matrix Is all this precision for each number really necessary? “A” Lowest frequencies Highest frequencies The JPEG Compression Algorithm
16
16 231 => 11100111 ≈ 11100000 (224) 62 => 0111110 ≈ 1000000 (64) 9 => 1001 ≈ 1000 (8) Worry only about storing the red bits! The JPEG Compression Algorithm
17
17 Throwing away trailing bits is easy divide by some number and discard fraction How many bits should we keep? Check the variance among blocks for each coefficient lower variance == less bits Create a corresponding “quantization matrix” that tells us how by much to divide each coefficient in every block 1611101624405161 12 141926586055 1413162440576956 1417222951878062 182237566810910377 243555648110411392 49647887103121120101 7292959811210010399 The JPEG Compression Algorithm
18
18 1611101624405161 12 141926586055 1413162440576956 1417222951878062 182237566810910377 243555648110411392 49647887103121120101 7292959811210010399 DCT coefficient matrix element-wise divided by quantization matrix (after rounding) =./ The JPEG Compression Algorithm
19
19 Zig-Zag Scan Why? -- to group low frequency coefficients in top of vector and high frequency coefficients at the bottom Maps 8 x 8 matrix to a 1 x 64 vector 8x8... 1x64
20
20 When we store these numbers, we must also keep track of how many zeros belong after each number: 14 = 1110 => represents the number 11100000 = 224 Store zero entries with just a single bit! Encode this using Huffman or other lossless scheme The JPEG Compression Algorithm
21
21 Rendering the compressed image Remultiply by the quantization matrix to get the coefficients Calculate IDCT Matrix of pixel intensitiesReassemble blocks The JPEG Compression Algorithm
22
22 Image Examples 248 X 324 X 3B
23
23 JPEG Compression Examples Quality still reasonable Some loss of fine detail 28:1 Compression Original Compressed
24
24 JPEG Compression Examples Quality drops dramatically as increase compression ratio Throws out color information first 66:1
25
25 JPEG Compression Examples 86:1 101:1
26
26 DCT Quantization Effects Blow Up Sections of Low Quality Images See 8 X 8 blocks Only low frequency coefficients for Y Extreme subsampling for U, V Single value for 16 X 8 pixels
27
27 JPEG Modes Lossless Mode: Truly lossless It is a predictive coding mechanism as opposed to the baseline mechanism which is based on DCT and quantization(the source of the loss). Here is the simple block diagram of the technique: Predictive Difference Huffman EnCoder Lossless Coding
28
28 Lossless Mode For each pixel a predictor (one of 7 possible) is used that best predicts the value contained in the pixel The difference between the predicted value and the actual value is used as the predictive difference to represent the pixel. The predictor along with the predictive difference are encoded The series of pixel values are encoded using huffman coding CB AX PredictorPrediction P1A P2B P3C P4A+B-C P5A + (B-C)/2 P6B + (A-C)/2 P7(A+B)/2
29
29 Progressive Mode It allows a coarse version of an image to be transmitted at a low rate, which is then progressively improved over subsequent transmissions. Spectral Selection : Send DC component and first few AC coefficients first, then gradually some more ACs. Spectral Selection: First Scan: Second Scan: Third Scan:.... N th Scan: Image Pixels
30
30 Progressive Mode Successive Approximation : All the DCT components are sent few bits at a time: For example, send n1 (say,4) bits (starting with MSB) of all pixels in the first scan, the next n2(say 1) bits of all pixels in the second and so on. Pixels ordered (zig-zag-wise) First Scan: Second Scan: Third Scan: 5 th Scan: 76540321 MSB LSB........... One Pixel
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.