Unformatted text preview:

Image File FormatsIndexed ColorImage CompressionGIFLZW CompressionJPEGDiscrete Cosine TransformQuantizationEntropy CodingLossless JPEG With PredictionColor QuantizationExampleQuantization ErrorUniform QuantizationSlide 15Populosity AlgorithmSlide 17Median CutSlide 19Optimization AlgorithmsCS559-Computer GraphicsCopyright Stephen ChenneyImage File Formats•How big is the image?–All files in some way store width and height•How is the image data formatted?–Is it a black and white image, a grayscale image, a color image, an indexed color image?–How many bits per pixel?•What other information?–Color tables, compression codebooks, creator information…CS559-Computer GraphicsCopyright Stephen ChenneyIndexed Color•24 bits per pixel (8-red, 8-green, 8-blue) are expensive to transmit and store•It must be possible to represent all those colors, but not in the same image•Solution: Indexed color–Assume k bits per pixel (typically 8)–Define a table containing 2k colors (24 bits each)–Store the index into the table for each pixelCS559-Computer GraphicsCopyright Stephen ChenneyImage Compression•Indexed color is one form of image compression–Special case of vector quantization•Alternative 1: Store the image in a simple format and then compress with your favorite compressor–Doesn’t exploit image specific information–Doesn’t exploit perceptual shortcuts•Two historically common compressed file formats: GIF and JPEG–GIF should now be replaced with PNGCS559-Computer GraphicsCopyright Stephen ChenneyGIF•Header – Color Table – Image Data – Extensions•Header gives basic information such as size of image and size of color table•Color table gives the colors found in the image–Biggest it can be is 256 colors, smallest is 2•Image data is LZW compressed color indicesCS559-Computer GraphicsCopyright Stephen ChenneyLZW Compression•Compresses a stream of “characters”, in GIF case they are 1byte color indices•Stores the strings encountered in a codebook–When compressing, strings are put in the codebook the second time they are encountered–Subsequent encounters replace the string with the code–Decoding reconstructs codebook on the fly–Advantage: The code does not need to be transmittedCS559-Computer GraphicsCopyright Stephen ChenneyJPEG•Multi-stage process intended to get very high compression with controllable quality degradation•All the images associated with the JPEG slides can be found on http://www.cs.sfu.ca/CourseCentral/365/li/material/notes/Chap4/Chap4.2/Chap4.2.htmlCS559-Computer GraphicsCopyright Stephen ChenneyDiscrete Cosine Transform•A transformation to convert from the spatial to frequency domain – done on 8x8 blocks•Why? Humans have varying sensitivity to different frequencies•Basis functions:CS559-Computer GraphicsCopyright Stephen ChenneyQuantization•Reduce the number of bits used to store each coefficient by dividing by a given value–Different coefficients are divided by different amounts–Perceptual issues come in here•Achieves the greatest compression, but also quality loss•“Quality” knob controls how much quantization is doneCS559-Computer GraphicsCopyright Stephen ChenneyEntropy Coding•Standard lossless compression on quantized coefficients–Delta encode the DC components–Run length encode the AC components•Lots of zeros, so store number of zeros then next value–Huffman code the encodingsCS559-Computer GraphicsCopyright Stephen ChenneyLossless JPEG With Prediction•Predict what the value of the pixel will be based on neighbors•Record error from prediction–Mostly error will be near zero•Huffman encode the error stream•Variation works really well for fax messagesCS559-Computer GraphicsCopyright Stephen ChenneyColor Quantization•The problem of reducing the number of colors in an image with minimal impact on appearance–Extreme case: 24 bit color to black and white–Less extreme: 24 bit color to 256 colors•Sub problems:–Decide which colors to use (if there is a choice)–Decide which of those each original color maps toCS559-Computer GraphicsCopyright Stephen ChenneyExampleThe example images shown in class came from:Gomes and Velho “Image Processing for Computer Graphics”,Springer, 1997CS559-Computer GraphicsCopyright Stephen ChenneyQuantization Error•A way of measuring the quality of our approximation•Define an error for each color, c, in the original image: d(c, c’), where c’ is the color c maps to under the quantization–Common is to use squared distance in RGB space–Should really use distance in CIE u’,v’ space•Sum up the error over all the pixelsCS559-Computer GraphicsCopyright Stephen ChenneyUniform Quantization•Break the color space into uniform cells•Find the cell that each color is in, and map it to the center•Generally does poorly because it fails to capture the distribution of colors–Some cells may be empty, and are wastedCS559-Computer GraphicsCopyright Stephen ChenneyUniform Quantization8 bits per pixel 4 bits per pixelCS559-Computer GraphicsCopyright Stephen ChenneyPopulosity Algorithm•Build a color histogram: count the number of times each color appears•Choose the n most commonly occurring colors–Typically group colors into small cells first•Map other colors to the closest chosen color•Problem: May completely ignore under-represented but important colorsCS559-Computer GraphicsCopyright Stephen ChenneyPopulosity Algorithm8 bits per pixel 4 bits per pixelCS559-Computer GraphicsCopyright Stephen ChenneyMedian Cut•Look at distribution of colors•Recursively:–Find the “longest” dimension–Choose the median as a color–Split along the median line, and recurse on both halves•Works very well in practiceCS559-Computer GraphicsCopyright Stephen ChenneyMedian Cut8 bits per pixel 4 bits per pixelCS559-Computer GraphicsCopyright Stephen ChenneyOptimization Algorithms•The quantization problem can be phrased as optimization–Find the set of colors and mapping that result in the lowest quantization error•Several methods to solve the problem, but of limited use unless the number of colors to be chosen is


View Full Document

UW-Madison CS 559 - Lecture 4

Documents in this Course
Filters

Filters

14 pages

Lecture 2

Lecture 2

24 pages

Clipping

Clipping

22 pages

Modeling

Modeling

33 pages

Filters

Filters

26 pages

Dithering

Dithering

33 pages

Load more
Download Lecture 4
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 4 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 4 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?