01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Last Time Color and Color Spaces.

Slides:



Advertisements
Similar presentations
1/29/04© University of Wisconsin, CS559 Spring 2004 Last Time Color –Sensor response is computed from the sensor’s response curve and the incoming spectrum.
Advertisements

T.Sharon-A.Frank 1 Multimedia Compression Basics.
Data Compression CS 147 Minh Nguyen.
Digital Color 24-bit Color Indexed Color Image file compression
Image Compression. Data and information Data is not the same thing as information. Data is the means with which information is expressed. The amount of.
Bit Depth and Spatial Resolution SIMG-201 Survey of Imaging Science © 2002 CIS/RIT.
SWE 423: Multimedia Systems
School of Computing Science Simon Fraser University
Department of Computer Engineering University of California at Santa Cruz Data Compression (3) Hai Tao.
Computer Science 335 Data Compression.
Graphics File Formats. 2 Graphics Data n Vector data –Lines –Polygons –Curves n Bitmap data –Array of pixels –Numerical values corresponding to gray-
CS :: Fall 2003 MPEG-1 Video (Part 1) Ketan Mayer-Patel.
CMPT 365 Multimedia Systems
T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid.
CS430 © 2006 Ray S. Babcock Lossy Compression Examples JPEG MPEG JPEG MPEG.
5. 1 JPEG “ JPEG ” is Joint Photographic Experts Group. compresses pictures which don't have sharp changes e.g. landscape pictures. May lose some of the.
Roger Cheng (JPEG slides courtesy of Brian Bailey) Spring 2007
1 JPEG Compression CSC361/661 Burg/Wong. 2 Fact about JPEG Compression JPEG stands for Joint Photographic Experts Group JPEG compression is used with.jpg.
Image Compression JPEG. Fact about JPEG Compression JPEG stands for Joint Photographic Experts Group JPEG compression is used with.jpg and can be embedded.
Spring 2015 Mathematics in Management Science Binary Linear Codes Two Examples.
09/12/02 (C) 2002, University of Wisconsin, CS 559 Last Time Color and Color Spaces –Recall RGB and XYZ Programming assignment 2.
Data starts with width and height of image Then an array of pixel values (colors) The number of elements in this array is width times height Colors can.
Image Compression - JPEG. Video Compression MPEG –Audio compression Lossy / perceptually lossless / lossless 3 layers Models based on speech generation.
Software Research Image Compression Mohamed N. Ahmed, Ph.D.
Trevor McCasland Arch Kelley.  Goal: reduce the size of stored files and data while retaining all necessary perceptual information  Used to create an.
CS559-Computer Graphics Copyright Stephen Chenney Image File Formats How big is the image? –All files in some way store width and height How is the image.
9/16/04© University of Wisconsin, CS559 Spring 2004 Last Time Color –The principle of trichromacy says that any spectrum can be matched using three primaries.
Page 18/30/2015 CSE 40373/60373: Multimedia Systems 4.2 Color Models in Images  Colors models and spaces used for stored, displayed, and printed images.
Introduction to JPEG Alireza Shafaei ( ) Fall 2005.
CS Spring 2012 CS 414 – Multimedia Systems Design Lecture 8 – JPEG Compression (Part 3) Klara Nahrstedt Spring 2012.
ECE472/572 - Lecture 12 Image Compression – Lossy Compression Techniques 11/10/11.
1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.
Lab #5-6 Follow-Up: More Python; Images Images ● A signal (e.g. sound, temperature infrared sensor reading) is a single (one- dimensional) quantity that.
2/3/04© University of Wisconsin, CS559 Spring 2004 Last Time Color –Transforming between two color spaces –A gamut is the set of displayable colors in.
: Chapter 12: Image Compression 1 Montri Karnjanadecha ac.th/~montri Image Processing.
Klara Nahrstedt Spring 2011
Concepts of Multimedia Processing and Transmission IT 481, Lecture 5 Dennis McCaughey, Ph.D. 19 February, 2007.
JPEG. The JPEG Standard JPEG is an image compression standard which was accepted as an international standard in  Developed by the Joint Photographic.
Data Compression. Compression? Compression refers to the ways in which the amount of data needed to store an image or other file can be reduced. This.
Indiana University Purdue University Fort Wayne Hongli Luo
JPEG CIS 658 Fall 2005.
Chapter 7 – End-to-End Data Two main topics Presentation formatting Compression We will go over the main issues in presentation formatting, but not much.
Addressing Image Compression Techniques on current Internet Technologies By: Eduardo J. Moreira & Onyeka Ezenwoye CIS-6931 Term Paper.
Digital Media Dr. Jim Rowan ITEC 2110 Bitmapped Images.
Understanding JPEG MIT-CETI Xi’an ‘99 Lecture 10 Ben Walter, Lan Chen, Wei Hu.
Digital Image Processing Image Compression
1 Image Formats. 2 Color representation An image = a collection of picture elements (pixels) Each pixel has a “color” Different types of pixels Binary.
Digital Media Lecture 4: Bitmapped images: Compression & Convolution Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan.
CS Spring 2014 CS 414 – Multimedia Systems Design Lecture 10 – Compression Basics and JPEG Compression (Part 4) Klara Nahrstedt Spring 2014.
09/17/02 (C) 2002, University of Wisconsin, CS 559 Last Time Color Spaces File formats.
Lecture 4: Lossless Compression(1) Hongli Luo Fall 2011.
02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.
The task of compression consists of two components, an encoding algorithm that takes a file and generates a “compressed” representation (hopefully with.
JPEG.
By Dr. Hadi AL Saadi Lossy Compression. Source coding is based on changing of the original image content. Also called semantic-based coding High compression.
JPEG Compression What is JPEG? Motivation
Data Compression.
Algorithms in the Real World
JPEG Image Coding Standard
JPEG.
Digital 2D Image Basic Masaki Hayashi
Data Compression.
Data Compression CS 147 Minh Nguyen.
CMPT 365 Multimedia Systems
Why Compress? To reduce the volume of data to be transmitted (text, fax, images) To reduce the bandwidth required for transmission and to reduce storage.
JPEG Pasi Fränti
Last Time Image – basic definition
Chapter 8 – Compression Aims: Outline the objectives of compression.
Presentation transcript:

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Last Time Color and Color Spaces

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Today Image file formats –GIF –JPEG Color Quantization –Uniform –Populosity –Median Cut –Optimization

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Image 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…

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 The Simplest File Assumes that the color depth is known and agreed on Store width, height, and data for every pixel in sequence This is how you normally store an image in memory Unsigned because width and height are positive, and unsigned char because it is the best type for raw 8 bit data Note that you require some implicit scheme for laying out a rectangular array into a linear one class Image { unsigned int width; unsigned int height; unsigned char *data; } 3 r,g,b 0r0r 0 r,g,b 1 r,g,b 2 r,g,b 4 r,g,b 5 r,g,b 8 r,g,b 7 r,g,b 6 r,g,b 0g0g 0b0b 1g1g 1r1r 1b1b 2r2r 2g2g 2b2b 3r3r 3g3g

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Indexed 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 color table containing 2 k colors (24 bits per color) –Store the index into the table for each pixel (so store k bits for each pixel) –Once common in hardware, now rare (256 color displays)

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Indexed Color Color Table Pixel DataImage Only makes sense if you have lots of pixels and not many colors

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Image 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 PNG, because GIF is patented and the owner started enforcing the patent

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 GIF 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 indices To create a GIF: –Choose colors –Create an array of color indices –Compress it with LZW

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 LZW 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 transmitted

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 JPEG Multi-stage process intended to get very high compression with controllable quality degradation Start with YIQ color –Why? Recall, it’s the color standard for TV

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Discrete Cosine Transform A transformation to convert from the spatial to frequency domain – done on 8x8 blocks Why? Humans have varying sensitivity to different frequencies, so it is safe to throw some of them away Basis functions:

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Quantization Reduce the number of bits used to store each coefficient by dividing by a given value –If you have an 8 bit number (0-255) and divide it by 8, you get a number between 0-31 (5 bits = 8 bits – 3 bits) –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 done

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Entropy 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 encodings

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Lossless 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 messages

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Color 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, or 256 grays Why do we care? Sub problems: –Decide which colors to use (if there is a choice) –Decide which of those each original color maps to

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Example (24 bit color)

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Quantization 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 pixels

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Uniform 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 wasted Equivalent to dividing each color by some number and taking the integer part –Say your original image is 24 bits color (8 red, 8 green, 8 blue) –Say you have 256 colors available, and you choose to use 8 reds, 8 greens and 4 blues (8 × 8 × 4 = 256 ) –Divide original red by 32, green by 32, and blue by 64

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Uniform Quantization 8 bits per pixel in this image Note that it does very poorly on smooth gradients Normally the hardest part to get right, because lots of similar colors appear very close together

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Populosity 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 colors

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Populosity Algorithm 8 bit image, so the most popular 256 colors Note that blue wasn’t very popular, so the crystal ball is now the same color as the floor

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Median Cut Look at distribution of colors Recursively: –Find the “longest” dimension (r, g, b are dimensions) –Choose the median of the long dimension as a color to use –Split along the median plane, and recurse on both halves Works very well in practice This algorithm is building a kD-tree, a common form of spatial data structure –Also used in nearest neighbor computations and many other areas of computer graphics

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Median Cut in Action Original colors in color space Median in long dimension Put median color in color table Recurse

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Median Cut 8 bit image, so 256 colors Now we get the blue Median cut works so well because it divides up the color space in the “most useful” way

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Optimization 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 small –It’s expensive to compute the optimum –It’s also a poorly behaved optimization

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Perceptual Problems While a good quantization may get close colors, humans still perceive the quantization Biggest problem: Mach bands –The difference between two colors is more pronounced when they are side by side and the boundary is smooth –This emphasizes boundaries between colors, even if the color difference is small –Rough boundaries are “averaged” by our vision system to give smooth variation

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Mach Bands in Reality The floor appears banded

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Mach Bands in Reality Still some banding even in this 24 bit image (the floor in the background)

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Mach bands Emphasized Note that each bar on the left appears to have color variation across it –Left edge appears darker than right The effect is entirely due to Mach banding

01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Next Lecture How to avoid Mach banding. The solution is dithering