ECE160 Spring 2011 Lecture 3 Graphics and Image Data Representations 1 ECE160 Multimedia Lecture 3: Spring 2011 Graphics and Image Data RepresentationsECE160 Spring 2011 Lecture 3 Graphics and Image Data Representations 2 Graphics and Image Data Representations • Graphics/Image Data Types • The number of file formats used in multimedia continues to proliferate. For example, a list of some file formats used in the popular product Macromedia Director.ECE160 Spring 2011 Lecture 3 Graphics and Image Data Representations 3 1-bit Images • Each pixel is stored as a single bit (0 or 1), so also referred to as binary image. • Such an image is also called a 1-bit monochrome image or a pure black/white image since it contains no color. • We show a sample 1-bit monochrome image (called “Lena“ by multimedia scientists - this is a standard image used to illustrate many algorithms).ECE160 Spring 2011 Lecture 3 Graphics and Image Data Representations 4 8-bit Gray-scale Images • Each pixel has a gray-value between 0 and 255. Each pixel is represented by a single byte; e.g., a dark pixel might have a value of 10, and a bright one might be 230. • Bitmap: The two-dimensional array of pixel values that represents the graphics/image data. • Image resolution refers to the number of pixels in a digital image (higher resolution always yields better quality). – Fairly high resolution for such an image might be 1600x1200, whereas lower resolution might be 640x480.ECE160 Spring 2011 Lecture 3 Graphics and Image Data Representations 5 Multimedia Presentation • Each pixel is usually stored as a byte (a value between 0 to 255), so a 640x480 grayscale image requires 300 kB of storage (640x480 = 307200). • We show the Lena image again, but this time in grayscale.ECE160 Spring 2011 Lecture 3 Graphics and Image Data Representations 6 Dithering • When an image is printed, the basic strategy of dithering is used, which trades intensity resolution for spatial resolution to provide ability to print multi-level images on 2-level (1-bit) printers. • Dithering calculates patterns of dots such that values from 0 to 255 correspond to patterns that are more and more filled at darker pixel values, for printing on a 1-bit printer. • The main strategy is to replace a pixel value by a larger pattern, say 22 or 44, such that the number of printed dots approximates the varying-sized disks of ink used in analog, in halftone printing (e.g., for newspaper photos). – Half-tone printing is an analog process that uses smaller or larger filled circles of black ink to represent shading, for newspaper printing.ECE160 Spring 2011 Lecture 3 Graphics and Image Data Representations 7 Dithering • For example, if we use a 2x2 dither matrix we can first re-map image values in 0..255 into the new range 0..4 by (integer) dividing by 256/5=51.2 Then, if the pixel value is 0 we print nothing, in a 2x2 area of printer output. But if the pixel value is 4 we print all four dots. • The rule is: – If the intensity is > the dither matrix entry then print an on dot at that entry location: replace each pixel by an nxn matrix of dots. • Note that the image size may be much larger, for a dithered image, since replacing each pixel by a 4x4 array of dots, makes an image 16 times as large.ECE160 Spring 2011 Lecture 3 Graphics and Image Data Representations 8 Dithering • A clever trick can get around this problem. Suppose we use a larger, 4x4 dither matrix, such as • An ordered dither consists of turning on the printer output bit for a pixel if the intensity level is greater than the particular matrix element just at that pixel positionECE160 Spring 2011 Lecture 3 Graphics and Image Data Representations 9 Dithering • An algorithm for ordered dither, with nxn dither matrix, is: BEGIN for x = 0 to xmax // columns for y = 0 to ymax // rows i =x mod n j =y mod n // I(x; y) is the input, O(x; y) is the output, // D is the dither matrix. if I(x; y) > D(i; j) O(x; y) = 1; else O(x; y) = 0; ENDECE160 Spring 2011 Lecture 3 Graphics and Image Data Representations 10 Dithering • A grayscale image of “Lena“ and an ordered dither version, with a detail of Lena's right eye.ECE160 Spring 2011 Lecture 3 Graphics and Image Data Representations 11 Image Data Types • The most common data types for graphics and image file formats - 24-bit color and 8-bit color. • Some formats are restricted to particular hardware/operating system platforms, while others are “cross-platform" formats. • Even if some formats are not cross-platform, there are conversion applications that will recognize and translate formats from one system to another. • Most image formats incorporate some variation of a compression technique due to the large storage size of image files. Compression techniques can be classified into either lossless or lossy.ECE160 Spring 2011 Lecture 3 Graphics and Image Data Representations 12 24-bit Color Images • In a color 24-bit image, each pixel is represented by three bytes, usually representing RGB. – This format supports 256x256x256 possible combined colors, or a total of 16,777,216 possible colors. – However such flexibility does result in a storage penalty: A 640x480 24-bit color image would require 921.6 kB of storage without any compression. • An important point: many 24-bit color images are actually stored as 32-bit images, with the extra byte of data for each pixel used to store an alpha value representing special effect information (e.g., transparency).ECE160 Spring 2011 Lecture 3 Graphics and Image Data Representations 13 24-bit Color Images • The image forestfire.bmp., a 24-bit image in Microsoft Windows BMP format. Also shown are the grayscale images for the Red, Green, and Blue channels, for this image.ECE160 Spring 2011 Lecture 3 Graphics and Image Data Representations 14 8-bit Color Images • Many systems can make use of 8 bits of color information (the so-called “256 colors") in producing a screen image. • Such images use the concept of a lookup table to store color information. – Basically, the image stores not color, but instead just a set of single bytes, each of which is actually an index into a table
View Full Document