Chapter 5 Bitmapped Images Multimedia Systems
Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed images, physical dimension = pixel dimension/device resolution. To display an image at its natural size it is scaled by device resolution/image resolution. To display an image at its natural size it is scaled by device resolution/image resolution. Downsampled images may look better than images stored at device resolution. Downsampled images may look better than images stored at device resolution.
Key Points Lossless compression: no information is lost during a compression/decompression cycle. Lossy compression: some information is discarded during the compression process. Lossless compression: no information is lost during a compression/decompression cycle. Lossy compression: some information is discarded during the compression process. Run-length encoding (RLE), Huffman encoding, and LZ77, LZ78 and LZW are lossless methods. GIFs use LZW. Run-length encoding (RLE), Huffman encoding, and LZ77, LZ78 and LZW are lossless methods. GIFs use LZW. JPEG compression is based on the use of the Discrete Cosine Transform (DCT). It is the most important lossy method for images. JPEG compression is based on the use of the Discrete Cosine Transform (DCT). It is the most important lossy method for images.
Key Points GIFs are best for simple shapes with areas of flat colour. JPEGs are best for photographs and other images with continuous tones. GIFs are best for simple shapes with areas of flat colour. JPEGs are best for photographs and other images with continuous tones. Selecting an area of pixels defines a mask which protects the rest of the image from changes that are applied. Selecting an area of pixels defines a mask which protects the rest of the image from changes that are applied. A grey-scale mask is called an alpha channel and can be used for feathering and compositing, amongst other things. A grey-scale mask is called an alpha channel and can be used for feathering and compositing, amongst other things. Pixel point processing: for a pixel with value p, we compute a new value p' = f(p). Brightness and contrast adjustments are common examples of pixel point processing. Pixel point processing: for a pixel with value p, we compute a new value p' = f(p). Brightness and contrast adjustments are common examples of pixel point processing.
Key Points Pixel group processing is based on a convolution process that also takes account of the values of neighboring pixels. Filters such as blurring and sharpening are the typical applications of pixel group processing. Pixel group processing is based on a convolution process that also takes account of the values of neighboring pixels. Filters such as blurring and sharpening are the typical applications of pixel group processing. In general, applying geometrical transformations to bitmapped images requires interpolation of pixels and may cause a loss of image quality. In general, applying geometrical transformations to bitmapped images requires interpolation of pixels and may cause a loss of image quality.
Resolution A measure of how finely a device approximates continuous images using finite pixels A measure of how finely a device approximates continuous images using finite pixels Dots per inch (dpi) Dots per inch (dpi) Printer: 600 dpi Printer: 600 dpi imagesetter (book production): dpi imagesetter (book production): dpi Scanner: dpi Scanner: dpi Drum scanners, transparency scanners: higher resolution Drum scanners, transparency scanners: higher resolution Lines per inch Lines per inch Colour printer of 150 lines per inch Colour printer of 150 lines per inch As much as 5 times lower than number of DPI As much as 5 times lower than number of DPI Frame size Frame size NTSC: 640 by 480 NTSC: 640 by 480 PAL: 768 by 576 PAL: 768 by 576 Computer monitors Computer monitors VGA: 640 by 480 VGA: 640 by by by 768 Dots per inch, 72 dpi Dots per inch, 72 dpi
Resolution Physical dimension Physical dimension physical dimension = pixel dimension / device resolution where device resolution is measured in pixels per unit length where device resolution is measured in pixels per unit length Image has pixel dimensions(ex. 300 by 200 pixels), but no physical dimension Image has pixel dimensions(ex. 300 by 200 pixels), but no physical dimension To display image at its natural size, record its pixels per inch (ppi) To display image at its natural size, record its pixels per inch (ppi)
Resolution If image's resolution < display device's resolution then interpolation of device's pixels (scaled up) If image's resolution < display device's resolution then interpolation of device's pixels (scaled up) If image's resolution > display device's resolution then discard image pixels (downsampling) If image's resolution > display device's resolution then discard image pixels (downsampling) Oversampling Oversampling Sampling images at a higher resolution than its ultimately displayed Sampling images at a higher resolution than its ultimately displayed Web browsers are poor at down-sampling Web browsers are poor at down-sampling down-sampling in advance down-sampling in advance
Image Compression Original data Compressed data encodedecode Lossless compression No information is lost Run-length encoding Huffman coding LZ77, LZ78, LZW,… Original data Compressed data Decompressed data encodedecode Lossy compression Discard some information JPEG
Lossless Compression Run-length encoding (RLE) Run-length encoding (RLE) replacing a run of consecutive pixels of the same color by color value and its count replacing a run of consecutive pixels of the same color by color value and its count ex ; 1 2 ; 0 2 ex ; 1 2 ; 0 2 encode color valuecount
Lossless Compression Huffman coding Huffman coding Using variable-length codes (VLC) according to its occurrence times Using variable-length codes (VLC) according to its occurrence times The more frequently it appears, the less code length it requires, and vice versa The more frequently it appears, the less code length it requires, and vice versa Dictionary-based compression Dictionary-based compression Construction a dictionary of strings, all occurrences of a string are replaced by a pointer into the dictionary Construction a dictionary of strings, all occurrences of a string are replaced by a pointer into the dictionary LZ77, LZ78, LZW (a variation of LZ78), … LZ77, LZ78, LZW (a variation of LZ78), … LZW: patented by Unisys LZW: patented by Unisys GIF: LZW, PNG: LZ77, PKZIP: LZ77 GIF: LZW, PNG: LZ77, PKZIP: LZ77
JPEG Compression JPEG JPEG Develop by Joint Photographic Experts Group Develop by Joint Photographic Experts Group Collaboration between ISO and CCITT (now ITU) Collaboration between ISO and CCITT (now ITU) Suit to compress digit photographs and bitmapped images Suit to compress digit photographs and bitmapped images Most widely known standard for lossy image compression Most widely known standard for lossy image compression
JPEG Encoding Step Shift pixel value (0~255 => -128~127) Shift pixel value (0~255 => -128~127) Divide image into blocks of size 8 8 Divide image into blocks of size 8 8 Use Discrete Cosine Transform (DCT) for each blocks Use Discrete Cosine Transform (DCT) for each blocks Quantize coefficients in block Quantize coefficients in block Apply Huffman codes for quantized coefficient Apply Huffman codes for quantized coefficient
Discrete Cosine Transform DCT of an N N pixel image DCT of an N N pixel image DCT uv = Where 0 <= u < N, 0 <= v < N, 1 / 2 for u, v = 0 1 otherwise p xy is the pixel value of x, y coordinate C u, C v =
Quantization Discard high frequencies information which do not contribute much perceived quality Discard high frequencies information which do not contribute much perceived quality Sample quantization table DCT coefficients in frequency domain After quantization low high Quantize
JPEG Encoding After quantization After quantization Many components end up with zero coefficients Many components end up with zero coefficients Fewer bits are needed to store non-zero coefficients Fewer bits are needed to store non-zero coefficients Zeros are run-length encoded Zeros are run-length encoded Scan with zig-zag sequence to max the length of runs of zeroes Scan with zig-zag sequence to max the length of runs of zeroes Apply Huffman coding Apply Huffman coding
JPEG Encoding Example An 8 * 8 block Shift & DCT transform DCT coefficients in frequency domain Quantization After using quantization table on coefficients Zig-zag scan Follow the scan to code coefficients
JPEG Decoding How to Decompression ? Just reverse compression process sequence! (but there is some information lost!) Frequency domain after decompression Original frequency domain
Compression Artefact Original image After JPEG compression (Produced by Photoshop)
Image Manipulation Why manipulate image? Why manipulate image? Correct deficiencies caused by creation or digitization Correct deficiencies caused by creation or digitization ex. Red-eye removal ex. Red-eye removal Create unnatural image Create unnatural image ex. Creating a glow around an object ex. Creating a glow around an object Image manipulation program Image manipulation program Adobe Photoshop, PhotoImpact Adobe Photoshop, PhotoImpact
Selections, Masks and Alpha Channels Selection Selection Defining an area within the image Defining an area within the image Tools Tools rectangular or elliptical marquee, lasso, rectangular or elliptical marquee, lasso, magic wand, and magnetic lasso Photoshop tools Elliptical marquee lasso magic wand
Selections, Masks and Alpha Channels Mask Mask The unselected area protect from any changes you make to the image The unselected area protect from any changes you make to the image Use single bit for each pixel: ‘1’ for all masked out pixels and ‘0’ for selection Use single bit for each pixel: ‘1’ for all masked out pixels and ‘0’ for selection Alpha channel Alpha channel Using more than one bit to specify transparency Using more than one bit to specify transparency compute composited image of a pixel p compute composited image of a pixel p where p 1, p 2 : the values of pixels in two original images α : normalized to lie between 0 and 1 α : normalized to lie between 0 and 1 p = αp 1 + (1 – α)p 2
Pixel Point Processing Compute a pixel’s new value p’ on its old value p, without regard to other pixel Compute a pixel’s new value p’ on its old value p, without regard to other pixel where f: mapping function ex. Construction a negative from greyscale(0~255) image f(p) = p f(p) = p p’ = f(p)
Pixel Point Processing Colour correction and alteration Colour correction and alteration Brightness Brightness Adjust the value of each pixel up or down uniformly Adjust the value of each pixel up or down uniformly Increasing makes every pixel lighter, decreasing make darker Increasing makes every pixel lighter, decreasing make darker Contrast Contrast Adjust the range between lightest and darkest areas of the image Adjust the range between lightest and darkest areas of the image Increasing contrast makes light areas lighter and dark areas darker, and vice versa Increasing contrast makes light areas lighter and dark areas darker, and vice versa Fig. 5.9 S-curve for enhancing contrast Fig. 5.9 S-curve for enhancing contrast
Pixel Group Processing Computing each pixel’s new value as a function of old value and neighboring pixels Computing each pixel’s new value as a function of old value and neighboring pixels Original Image Convolution mask New image Convolution kernel * = ( ) i
Pixel Group Processing Original image Convolution mask New image a b c d h ef gi p (x,y) p’ = ap x-1,y+1 + bp x,y+1 + cp x+1,y+1 + dp x-1,y + ep x,y + fp x+1,y + gp x-1,y-1 + hp x,y-1 + ip x+1,y-1 p’
Filter Blur Blur Filter Filter ex. ex. In signal processing, smoothing effect is obtained by filtering out high frequencies (low pass filter) In signal processing, smoothing effect is obtained by filtering out high frequencies (low pass filter) 1/9 1/9 1/ /9 1/9 1/9 *
Filter Gaussian blur Gaussian blur Gaussian bell curve Gaussian bell curve Roughly 70% contribution to the centre pixel Roughly 70% contribution to the centre pixel Sharpen Sharpen Filter Filter ex. ex *
Filter Unsharp masking Unsharp masking Accentuate the edges, but retain the other parts Accentuate the edges, but retain the other parts Idea Idea Blurring filters out high frequencies Blurring filters out high frequencies If remove blurred image away from origin, it left high frequencies – the sharp edges If remove blurred image away from origin, it left high frequencies – the sharp edges Step Step Copy original image, applying a Gaussian blur to it Copy original image, applying a Gaussian blur to it Subtracting the blurred mask pixel value from original pixel value with scaling factor Subtracting the blurred mask pixel value from original pixel value with scaling factor
origin blur sharp Unsharp mask (Produced by Photoshop)
Filter Image I blur Image I’Image I’’ sharp Image I blur Image I’Image I’’ sharp Is I = I’’ ?
Geometrical Transformations Scaling, translation, reflection, rotation and shearing Scaling, translation, reflection, rotation and shearing Two transformation schemes Two transformation schemes Forward mapping Forward mapping Assign original pixel value to transformed pixel Assign original pixel value to transformed pixel Inverse mapping Inverse mapping For each transformed pixel, find its inverse pixel value in original image For each transformed pixel, find its inverse pixel value in original image Advantage Advantage No missing pixels No missing pixels Disadvantage Disadvantage Require inverse mapping Require inverse mapping
Sampling Methods of Inverse Mapping P1P1 P2P2 P3P3 P4P4 If transformed pixel ‘X’ locates among P 1, P 2, P 3 and P 4 Nearest neighbor method: I(‘X’) = I(P 3 ) where I(p) is the intensity value of pixel p Bi-linear interpolation: I(‘X’) = (1-a)(1-b)I( P 1 ) + a(1-b)I(P 2 ) + (1-a)bI(P 3 ) + abI(P 4 ) where a, b are the fractional parts of ‘X’ Bi-cubic interpolation: based on cubic splines
Original image * 2 Bi-linear interpolation Bi-cubic interpolation