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.

Slides:



Advertisements
Similar presentations
JPEG Compresses real images Standard set by the Joint Photographic Experts Group in 1991.
Advertisements

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.
Data Compression CS 147 Minh Nguyen.
Time-Frequency Analysis Analyzing sounds as a sequence of frames
Digital Color 24-bit Color Indexed Color Image file compression
Digital Image Processing Lecture 3: Image Display & Enhancement
 Image Characteristics  Image Digitization Spatial domain Intensity domain 1.
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.
1 Image Filtering Readings: Ch 5: 5.4, 5.5, 5.6,5.7.3, 5.8 (This lecture does not follow the book.) Images by Pawan SinhaPawan Sinha formal terminology.
Losslessy Compression of Multimedia Data Hao Jiang Computer Science Department Sept. 25, 2007.
Half Toning. Continuous Half Toning Color Half Toning.
CS :: Fall 2003 MPEG-1 Video (Part 1) Ketan Mayer-Patel.
Image Enhancement.
CMPT 365 Multimedia Systems
T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid.
Multimedia Data The DCT and JPEG Image Compression Dr Mike Spann Electronic, Electrical and Computer.
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.
09/12/02 (C) 2002, University of Wisconsin, CS 559 Last Time Color and Color Spaces –Recall RGB and XYZ Programming assignment 2.
01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Last Time Color and Color Spaces.
Image Compression - JPEG. Video Compression MPEG –Audio compression Lossy / perceptually lossless / lossless 3 layers Models based on speech generation.
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.
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.
IDL GUI for Digital Halftoning Final Project for SIMG-726 Computing For Imaging Science Changmeng Liu
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.
Klara Nahrstedt Spring 2011
Simple Image Processing Speaker : Lin Hsiu-Ting Date : 2005 / 04 / 27.
JPEG. The JPEG Standard JPEG is an image compression standard which was accepted as an international standard in  Developed by the Joint Photographic.
Indiana University Purdue University Fort Wayne Hongli Luo
09/19/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Dithering.
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 Image Processing Lecture 3: Image Display & Enhancement March 2, 2005 Prof. Charlene Tsai.
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.
DIGITAL IMAGE. Basic Image Concepts An image is a spatial representation of an object An image can be thought of as a function with resulting values of.
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.
CS654: Digital Image Analysis
STATISTIC & INFORMATION THEORY (CSNB134) MODULE 11 COMPRESSION.
Introduction to JPEG m Akram Ben Ahmed
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.
1 of 32 Computer Graphics Color. 2 of 32 Basics Of Color elements of color:
MP3 and AAC Trac D. Tran ECE Department The Johns Hopkins University Baltimore MD
Masaki Hayashi 2015, Autumn Visualization with 3D CG Digital 2D Image Basic.
Misc. Non-linear Image Processing - Pixel to pixel operations - Histogram equalization - Grey level and colour enhancement - Neighbourhood operations.
JPEG Compression What is JPEG? Motivation
Chapter 9 Image Compression Standards
Data Compression.
Algorithms in the Real World
JPEG.
Digital 2D Image Basic Masaki Hayashi
Data Compression.
Data Compression CS 147 Minh Nguyen.
CMPT 365 Multimedia Systems
Digital Image Processing
Last Time Image – basic definition
Presentation transcript:

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 a color space –A perceptually uniform allows you to reasonably compare local color distances –Printers use subtractive color Image Files –Must store at least width/height/pixels –Indexed color uses a color table to reduce the cost of storing the image, but can show fewer colors in a single image

2/3/04© University of Wisconsin, CS559 Spring 2004 Today JPEG images Color quantization Dithering Homework 1 due, here, now

2/3/04© University of Wisconsin, CS559 Spring 2004 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

2/3/04© University of Wisconsin, CS559 Spring 2004 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: –Each block of 8x8 pixels is a linear combination of these images

2/3/04© University of Wisconsin, CS559 Spring 2004 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

2/3/04© University of Wisconsin, CS559 Spring 2004 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

2/3/04© University of Wisconsin, CS559 Spring 2004 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 Works really well for fax messages

2/3/04© University of Wisconsin, CS559 Spring 2004 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 in the output (if there is a choice) –Decide which of those colors should be used for each input pixel

2/3/04© University of Wisconsin, CS559 Spring 2004 Example (24 bit color)

2/3/04© University of Wisconsin, CS559 Spring 2004 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 –Some annoying details

2/3/04© University of Wisconsin, CS559 Spring 2004 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 Does this scheme use information from the image?

2/3/04© University of Wisconsin, CS559 Spring 2004 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 using uniform quantization Map other colors to the closest chosen color Problem?

2/3/04© University of Wisconsin, CS559 Spring 2004 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 Populosity ignores rare but important colors!

2/3/04© University of Wisconsin, CS559 Spring 2004 Median Cut (Clustering) View the problem as a clustering problem –Find groups of colors that are similar (a cluster) –Replace each input color with one representative of its cluster Many algorithms for clustering Median Cut is one: recursively –Find the “longest” dimension (r, g, b are dimensions) –Choose the median of the long dimension as a color to use –Split into two sub-clusters along the median plane, and recurse on both halves Works very well in practice

2/3/04© University of Wisconsin, CS559 Spring 2004 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

2/3/04© University of Wisconsin, CS559 Spring 2004 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

2/3/04© University of Wisconsin, CS559 Spring 2004 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

2/3/04© University of Wisconsin, CS559 Spring 2004 Mach Bands in Reality The floor appears banded

2/3/04© University of Wisconsin, CS559 Spring 2004 Mach Bands in Reality Still some banding even in this 24 bit image (the floor in the background)

2/3/04© University of Wisconsin, CS559 Spring 2004 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

2/3/04© University of Wisconsin, CS559 Spring 2004 Dithering (Digital Halftoning) Mach bands can be removed by adding noise along the boundary lines General perceptive principle: replaced structured errors with noisy ones and people complain less Old industry dating to the late 1800’s –Methods for producing grayscale images in newspapers and books

2/3/04© University of Wisconsin, CS559 Spring 2004 Dithering to Black-and-White Black-and-white is still the preferred way of displaying images in many areas –Black ink is cheaper than color –Printing with black ink is simpler and hence cheaper –Paper for black inks is not special To get color to black and white, first turn into grayscale: I=0.299R+0.587G+0.114B –This formula reflects the fact that green is more representative of perceived brightness than blue is –NOTE that it is not the equation implied by the RGB->XYZ color space conversion matrix

2/3/04© University of Wisconsin, CS559 Spring 2004 Sample Images

2/3/04© University of Wisconsin, CS559 Spring 2004 Threshold Dithering For every pixel: If the intensity < 0.5, replace with black, else replace with white –0.5 is the threshold –This is the naïve version of the algorithm To keep the overall image brightness the same, you should: –Compute the average intensity over the image –Use a threshold that gives that average –For example, if the average intensity is 0.6, use a threshold that is higher than 40% of the pixels, and lower than the remaining 60% For all dithering we will assume that the image is gray and that intensities are represented as a value in [0, 1.0] –If you have a image, you can scale all the thresholds (multiply by 255)

2/3/04© University of Wisconsin, CS559 Spring 2004 Naïve Threshold Algorithm

2/3/04© University of Wisconsin, CS559 Spring 2004 Random Modulation Add a random amount to each pixel before thresholding –Typically add uniformly random amount from [-a,a] Pure addition of noise to the image –For better results, add better quality noise –For instance, use Gaussian noise (random values sampled from a normal distribution) Should use same procedure as before for choosing threshold Not good for black and white, but OK for more colors –Add a small random color to each pixel before finding the closest color in the table

2/3/04© University of Wisconsin, CS559 Spring 2004 Random Modulation

2/3/04© University of Wisconsin, CS559 Spring 2004 Ordered Dithering Break the image into small blocks Define a threshold matrix –Use a different threshold for each pixel of the block –Compare each pixel to its own threshold The thresholds can be clustered, which looks like newsprint The thresholds can be “random” which looks better Threshold matrix

2/3/04© University of Wisconsin, CS559 Spring 2004 Clustered Dithering

2/3/04© University of Wisconsin, CS559 Spring 2004 Dot Dispersion

2/3/04© University of Wisconsin, CS559 Spring 2004 Pattern Dithering Compute the intensity of each sub-block and index a pattern NOT the same as before –Here, each sub-block has one of a fixed number of patterns – pixel is determined only by average intensity of sub-block –In ordered dithering, each pixel is checked against the dithering matrix before being turned on

2/3/04© University of Wisconsin, CS559 Spring 2004 Floyd-Steinberg Dithering Start at one corner and work through image pixel by pixel –Usually scan top to bottom in a zig-zag Threshold each pixel Compute the error at that pixel: The difference between what should be there and what you did put there Propagate error to neighbors by adding some proportion of the error to each unprocessed neighbor –Mask tells you how much to add e 3/165/161/16 7/16

2/3/04© University of Wisconsin, CS559 Spring 2004 Floyd-Steinberg Dithering

2/3/04© University of Wisconsin, CS559 Spring 2004 Color Dithering All the same techniques can be applied, with some modification –Below is Floyd-Steinberg: Error is difference from nearest color in the color table, error propagation is the same