280 likes | 639 Views
Travis Roe Topics of Computer Science . Image File Formats A Review of Common Image Storage Formats. Objectives. Image File Formats Compression Lossless Lossy Comparisons Applications Resources/References Questions. Image File Formats. Uncompressed
E N D
Travis Roe Topics of Computer Science Image File FormatsA Review of Common Image Storage Formats
Objectives • Image File Formats • Compression • Lossless • Lossy • Comparisons • Applications • Resources/References • Questions
Image File Formats • Uncompressed • BMP (generally, although not always) • PPM (text, sometimes) • Compressed - Lossless • GIF • PNG • Compressed - Lossy • JPEG
Lossy Compression • Lossless (xkcd 331)
CompressionLossless • Reconstruct images with the same bit patterns as before • Often compress artificial images, or images with sharp lines very well. • Useful for storing images with sections of continuous color (or lack of color – transparency)
PNG 1-48 bit color depth(16 bit grayscale) Up to 8-bit color pallete Full alpha channel (256 levels of transparency) Single-image (MNG handles multiple) Free!(was designed partially to replace GIF) CompressionLossless - GIF and PNG comparison GIF • 1-8 bit color depth • Up to 8-bit color pallete • Single color transparency • Multiple-images per file • Patented
CompressionLossless – A Terror to Compression • Every single color possible in 24 bit color.http://www.libpng.org/pub/png/img_png/16million.png • How do we handle that!? Huffman encoding cries! • GIFs do not have enough color depth to represent them (they weren't designed for it, anyway) • PNGs handle this: • Uncompressed 48MB • Compressed (w/o Filters) 36MB • Filters 113KB (PNG book explained it could be even smaller!)
CompressionLossless – PNG • Uses filters (a different filter can be used for each line) to simplify compression • None (bytes are unchanged) • Subtract (the difference of one pixel to the one before it) • Up (the difference of one pixel to the one above it) • Average (the difference between one pixel and the ones to the left and above it) • Paeth (based on Paeth predictor) (adapted from Roelofs, Table 9-1, p148)
CompressionLossy • Sacrifices perfect storage for lower file sizes, yet still acceptable images. • Good for photographs • Not designed for sharp edges and text. • Not designed as an intermediate format for post-processing
When you repeatedly save-and-load-and-save-and-load a lossy-ly compressed image, more of the image's data disappears. CompressionLossy – Maluse
As stated earlier, another thing that lossy image file formats are not designed for is text and sharp lines. CompressionLossy – Maluse 2
CompressionLossy – Maluse 2 (examples) • Compression artifacts can do great damage to text, especially at higher compression levels (lower quality images)(example is at 40% compression)
Comparisons • Real-World Examples • Comic Book with Text • Dog • 2 “Drawings”
ComparisonsComic Book with Text • Original file (PNG): 21.2kB • JPEG @ 25%(approx same size, quality still acceptably good) • GIF (4 bit) 13.7kB • PNG (my version, 4 bit): 12.5kB
ComparisonsDog (512 x 768) • JPEG (10%): 134kB • PNG (24bit): 659kB • PNG (8 bit pallete): 188kB
ComparisonsDog (JPEG vs Palleted PNG) JPEG : 134kB PNG: 188kB
ComparisonsDrawing 1 • PNG: 159kB • JPEG (5%)103kB(there were noticable compression artifacts when zoomed to 300%) • PNG (pallete, dithered): 106kB
ComparisonsDrawing 1 (24bit PNG vs 8-bit PNG 24 bit PNG 8-bit PNG (pallete)
ComparisonsDrawing 2 • PNG: 33.8kB • JPEG (10%): 36.5kB • JPEG (5%): 51.7kB • PNG (pallete, dithered): 24.2kB (no noticable difference between 24bit PNG and 8-bit palleted one)
Applications • So what does this have to do with CS? • Many programs use images. Finding out the most appropriate format for the job and then using it can save space. That is especially useful when programs are restricted in space (like a cell phone or a game that's near the edge of the CD/DVD limit) • Web developers want to keep their bandwidth to a minimum. Reducing the amount of space needed to store the same image helps.
Resources/ReferencesResources Used • Image Editing Software • Corel Paint Shop Pro Photo XI (version 11.20) • The GIMP 2.4.1 (Windows Version) • Picasa2 (primarily for browsing) • Camera Used • Canon Digital Rebel (EOS 300D)
Resources/ReferencesReferences • 16million.jpg http://www.libpng.org/pub/png/img_png/16million.png • Roelofs, Greg. PNG: The Definitive Guide. O'Reilly & Associates. 1999. (also available online at: http://www.oreilly.com/catalog/pngdefg/ ) • Wolfgang, Ray. “JPEG Tutorial”. Perdue University. http://cobweb.ecn.purdue.edu/~ace/jpeg-tut/jpegtut1.html • XKCD episode 331: http://xkcd.com/331/
Questions • When saving an image like a photograph, what's the most appropriate kind of file format to use? • If an image has a range of transparency, what file format should be used to render it?