chapter 5 bitmapped images multimedia systems. key points for displayed images, physical dimension =...

34
Chapter 5 Chapter 5 Bitmapped Images Bitmapped Images Multimedia Systems Multimedia Systems

Upload: daniel-shepherd

Post on 02-Jan-2016

226 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

Chapter 5Chapter 5Bitmapped ImagesBitmapped Images

Multimedia SystemsMultimedia Systems

Page 2: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

Key PointsKey Points For displayed images, For displayed images, physical dimensiophysical dimensio

n = pixel dimension/device resolutionn = pixel dimension/device resolution. . To display an image at its natural size it iTo display an image at its natural size it i

s scaled by s scaled by device resolution/image resodevice resolution/image resolutionlution. .

DownsampledDownsampled images may look better t images may look better than images stored at device resolution. han images stored at device resolution.

Page 3: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

Key PointsKey Points LosslessLossless compression: no information is lost d compression: no information is lost d

uring a compression/decompression cycle.uring a compression/decompression cycle.LossyLossy compression: some information is disca compression: some information is discarded during the compression process. rded during the compression process.

Run-length encoding (RLE)Run-length encoding (RLE), , HuffmanHuffman encodi encoding, and ng, and LZ77, LZ78 and LZWLZ77, LZ78 and LZW are lossless meth are lossless methods.ods.GIFs use LZW. GIFs use LZW.

JPEGJPEG compression is based on the use of the compression is based on the use of the Discrete Cosine Transform (DCT)Discrete Cosine Transform (DCT)..It is the most important lossy method for imagIt is the most important lossy method for images. es.

Page 4: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

Key PointsKey Points GIFs are best for simple shapes with areas of flGIFs are best for simple shapes with areas of fl

at colour.at colour.JPEGs are best for photographs and other imaJPEGs are best for photographs and other images with continuous tones. ges with continuous tones.

SelectingSelecting an area of pixels defines a an area of pixels defines a maskmask whi which protects the rest of the image from changes ch protects the rest of the image from changes that are applied. that are applied.

A grey-scale mask is called an A grey-scale mask is called an alpha channelalpha channel a and can be used for feathering and compositing,nd can be used for feathering and compositing, amongst other things. amongst other things.

Pixel point processingPixel point processing: for a pixel with value : for a pixel with value pp, we compute a new value , we compute a new value p' = f(p)p' = f(p)..BrightnessBrightness and and contrastcontrast adjustments are co adjustments are common examples of pixel point processing. mmon examples of pixel point processing.

Page 5: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

Key PointsKey Points

Pixel group processingPixel group processing is based on is based on a a convolutionconvolution process that also process that also takes account of the values of takes account of the values of neighboring pixels.neighboring pixels.FiltersFilters such as such as blurringblurring and and sharpeningsharpening are the typical are the typical applications of pixel group processing. applications of pixel group processing.

In general, applying In general, applying geometrical geometrical transformationstransformations to bitmapped to bitmapped images requires images requires interpolationinterpolation of of pixels and may cause a loss of image pixels and may cause a loss of image quality. quality.

Page 6: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

ResolutionResolution A measure of how finely a device approximates continA measure of how finely a device approximates contin

uous images using finite pixelsuous images using finite pixels Dots per inch (dpi)Dots per inch (dpi)

Printer: 600 dpiPrinter: 600 dpi imagesetter (book production): 1200-2700 dpiimagesetter (book production): 1200-2700 dpi Scanner: 300-3600 dpiScanner: 300-3600 dpi Drum scanners, transparency scanners: higher resolutionDrum scanners, transparency scanners: higher resolution

Lines per inchLines per inch Colour printer of 150 lines per inchColour printer of 150 lines per inch As much as 5 times lower than number of DPIAs much as 5 times lower than number of DPI

Frame sizeFrame size NTSC: 640 by 480NTSC: 640 by 480 PAL: 768 by 576PAL: 768 by 576

Computer monitorsComputer monitors VGA: 640 by 480VGA: 640 by 480 1027 by 7681027 by 768 Dots per inch, 72 dpiDots per inch, 72 dpi

Page 7: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

ResolutionResolution Physical dimensionPhysical dimension

physical dimension = pixel dimension / device resolution

where device resolution is measured in pixels per unit lengthwhere device resolution is measured in pixels per unit length Image has pixel dimensions(ex. 300 by 200 pImage has pixel dimensions(ex. 300 by 200 p

ixels), but no physical dimensionixels), but no physical dimension To display image at its natural size, record itTo display image at its natural size, record it

s pixels per inch (ppi)s pixels per inch (ppi)

Page 8: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

ResolutionResolution If image's resolution < display device's resolutiIf image's resolution < display device's resoluti

ononthen interpolation of device's pixels (scaled up)then interpolation of device's pixels (scaled up)

If image's resolution > display device's resolutiIf image's resolution > display device's resolutiononthen discard image pixels (downsampling)then discard image pixels (downsampling)

OversamplingOversampling Sampling images at a higher resolution than its ultiSampling images at a higher resolution than its ulti

mately displayedmately displayed Web browsers are poor at down-samplingWeb browsers are poor at down-sampling

down-sampling in advancedown-sampling in advance

Page 9: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

Image CompressionImage Compression

Original data

Compressed data

encodedecode

Lossless compression No information is lost

Run-length encodingHuffman codingLZ77, LZ78, LZW,…

Original data

Compressed data

Decompressed data

encode decode

Lossy compression Discard some information

JPEG

Page 10: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

Lossless CompressionLossless Compression Run-length encoding (RLE)Run-length encoding (RLE)

replacing a run of consecutive pixels of replacing a run of consecutive pixels of the same color by color value and its the same color by color value and its count count

ex. 00001100 0 ex. 00001100 0 44 ; 1 ; 1 22 ; 0 ; 0 22encode

color value count

Page 11: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

Lossless CompressionLossless Compression Huffman codingHuffman coding

Using variable-length codes (VLC) Using variable-length codes (VLC) according to its occurrence timesaccording to its occurrence times

The more frequently it appears, the less The more frequently it appears, the less code length it requires, and vice versacode length it requires, and vice versa

Dictionary-based compressionDictionary-based compression Construction a dictionary of strings, all Construction a dictionary of strings, all

occurrences of a string are replaced by occurrences of a string are replaced by a pointer into the dictionarya pointer into the dictionary

LZ77, LZ78, LZW (a variation of LZ78),…LZ77, LZ78, LZW (a variation of LZ78),… LZW: patented by UnisysLZW: patented by Unisys GIF: LZW, PNG: LZ77, PKZIP: LZ77GIF: LZW, PNG: LZ77, PKZIP: LZ77

Page 12: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

JPEG CompressionJPEG Compression JPEGJPEG

Develop by Joint Photographic Experts Develop by Joint Photographic Experts GroupGroup

Collaboration between ISO and CCITT (now Collaboration between ISO and CCITT (now ITU)ITU)

Suit to compress Suit to compress digit photographsdigit photographs and and bitmapped imagesbitmapped images

Most widely known standard for Most widely known standard for lossylossy image compressionimage compression

Page 13: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

JPEG Encoding StepJPEG Encoding Step Shift pixel valueShift pixel value (0~255 => - (0~255 => -

128~127)128~127) Divide image into blocks of size Divide image into blocks of size 8 8 8 8 Use Discrete Cosine Transform (Use Discrete Cosine Transform (DCTDCT) )

for each blocksfor each blocks Quantize coefficients in blockQuantize coefficients in block Apply Apply HuffmanHuffman codes for quantized codes for quantized

coefficientcoefficient

Page 14: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

Discrete Cosine TransformDiscrete Cosine Transform DCT of an DCT of an N N NN pixel image pixel image DCTDCTuvuv = =

]2

)12(cos[]

2

)12(cos[

2

1 1

0

1

0 N

vy

N

uxpCC

N

N

x

N

yxyvu

Where 0 <= u < N, 0 <= v < N,

1 / 2 for u, v = 0 1 otherwise

pxy is the pixel value of x, y coordinate

Cu, Cv =

Page 15: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

QuantizationQuantization Discard high frequencies Discard high frequencies

information which do not information which do not contribute much perceived qualitycontribute much perceived quality

16 11 10 16 24 40 51 6112 12 14 19 26 58 60 5514 13 16 24 40 57 69 5614 17 22 29 51 87 80 6218 22 37 56 68 109 103 7724 35 55 64 81 104 113 9249 64 78 87 103 121 120 10172 92 95 98 112 100 103 99

Sample quantization table

39.8 6.5 -2.4 1.2 -0.3 -1.0 0.7 1.1-102.4 4.5 2.2 1.1 0.3 -0.6 -1.0 -0.4 37.7 1.3 1.7 0.2 -1.5 -2.2 -0.1 0.2 -5.6 2.2 -1.3 -0.8 1.4 0.2 0.1 0.1 -3.3 -0.7 -1.7 0.7 -0.6 -2.6 -1.3 0.7 5.9 -0.1 -0.4 -0.7 1.9 -0.2 1.4 0.0 3.9 5.5 2.3 -0.5 0.0 -0.8 -0.5 -0.1 -3.4 0.5 -1.0 0.8 0.9 0.0 0.3 0.0

DCT coefficients in frequency domain

2 1 0 0 0 0 0 0 -9 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

After quantization

low high

high

Quantize

Page 16: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

JPEG EncodingJPEG Encoding After quantizationAfter quantization

Many components end up with zero Many components end up with zero coefficientscoefficients

Fewer bits are needed to store non-zero Fewer bits are needed to store non-zero coefficientscoefficients

Zeros are run-length encodedZeros are run-length encoded Scan with zig-zag sequence to max the Scan with zig-zag sequence to max the

length of runs of zeroeslength of runs of zeroes

Apply Huffman codingApply Huffman coding

Page 17: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

JPEG Encoding ExampleJPEG Encoding Example

124 125 122 120 122 119 117 118121 121 120 119 119 120 120 118126 124 123 122 121 121 120 120124 124 125 125 126 125 124 124127 127 128 129 130 128 127 125143 142 143 142 140 139 139 139150 148 152 152 152 152 150 151156 159 158 155 158 158 157 156

An 8 * 8 block

Shift &DCT transform

39.8 6.5 -2.4 1.2 -0.3 -1.0 0.7 1.1-102.4 4.5 2.2 1.1 0.3 -0.6 -1.0 -0.4 37.7 1.3 1.7 0.2 -1.5 -2.2 -0.1 0.2 -5.6 2.2 -1.3 -0.8 1.4 0.2 0.1 0.1 -3.3 -0.7 -1.7 0.7 -0.6 -2.6 -1.3 0.7 5.9 -0.1 -0.4 -0.7 1.9 -0.2 1.4 0.0 3.9 5.5 2.3 -0.5 0.0 -0.8 -0.5 -0.1 -3.4 0.5 -1.0 0.8 0.9 0.0 0.3 0.0

DCT coefficients in frequency domain

Quantization

2 1 0 0 0 0 0 0 -9 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

After using quantization table on coefficients

2 1 0 0 0 0 0 0 -9 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Zig-zag scan

Follow the scan to code coefficients

Page 18: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

JPEG DecodingJPEG Decoding

How to Decompression ?

Just reverse compression process sequence!(but there is some information lost!)

32 11 0 0 0 0 0 0-108 0 0 0 0 0 0 0 42 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

39.8 6.5 -2.4 1.2 -0.3 -1.0 0.7 1.1-102.4 4.5 2.2 1.1 0.3 -0.6 -1.0 -0.4 37.7 1.3 1.7 0.2 -1.5 -2.2 -0.1 0.2 -5.6 2.2 -1.3 -0.8 1.4 0.2 0.1 0.1 -3.3 -0.7 -1.7 0.7 -0.6 -2.6 -1.3 0.7 5.9 -0.1 -0.4 -0.7 1.9 -0.2 1.4 0.0 3.9 5.5 2.3 -0.5 0.0 -0.8 -0.5 -0.1 -3.4 0.5 -1.0 0.8 0.9 0.0 0.3 0.0

Frequency domain after decompression Original frequency domain

Page 19: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

Compression ArtefactCompression Artefact

Original image After JPEG compression

(Produced by Photoshop)

Page 20: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

Image ManipulationImage Manipulation Why manipulate image?Why manipulate image?

Correct deficiencies caused by creation or diCorrect deficiencies caused by creation or digitizationgitization

ex. Red-eye removalex. Red-eye removal Create unnatural imageCreate unnatural image

ex. Creating a glow around an objectex. Creating a glow around an object Image manipulation programImage manipulation program

Adobe Photoshop, PhotoImpactAdobe Photoshop, PhotoImpact

Page 21: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

Selections, MasksSelections, Masksand Alpha Channelsand Alpha Channels

SelectionSelection Defining an area within the imageDefining an area within the image ToolsTools

rectangular or elliptical marquee, lasso,rectangular or elliptical marquee, lasso,

magic wand, and magnetic lassomagic wand, and magnetic lasso

Photoshoptools

Ellipticalmarquee

lasso magicwand

Page 22: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

Selections, MasksSelections, Masksand Alpha Channelsand Alpha Channels

MaskMask The unselected area protect from any changes The unselected area protect from any changes

you make to the imageyou make to the image Use single bit for each pixel: ‘1’ for all masked Use single bit for each pixel: ‘1’ for all masked

out pixels and ‘0’ for selectionout pixels and ‘0’ for selection Alpha channelAlpha channel

Using more than one bit to specify transparencyUsing more than one bit to specify transparency compute composited image of a pixel compute composited image of a pixel pp

where where pp11, p, p22: the values of pixels in two original images: the values of pixels in two original images αα : normalized to lie between 0 and 1 : normalized to lie between 0 and 1

p = αp1 + (1 – α)p2

Page 23: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

Pixel Point ProcessingPixel Point Processing Compute a pixel’s new value Compute a pixel’s new value p’p’ on on

its old value its old value pp, without regard to , without regard to other pixelother pixel

where where ff: mapping function: mapping function

ex. Construction a negative from greyscale(0~255) imageex. Construction a negative from greyscale(0~255) image

f(p) = 255 - pf(p) = 255 - p

p’ = f(p)

Page 24: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

Pixel Point ProcessingPixel Point Processing Colour correction and alterationColour correction and alteration

BrightnessBrightness Adjust the value of each pixel up or down Adjust the value of each pixel up or down

uniformlyuniformly Increasing makes every pixel lighter, Increasing makes every pixel lighter,

decreasing make darkerdecreasing make darker ContrastContrast

Adjust the range between lightest and darkest Adjust the range between lightest and darkest areas of the imageareas of the image

Increasing contrast makes light areas lighter Increasing contrast makes light areas lighter and dark areas darker, and vice versaand dark areas darker, and vice versa

Fig. 5.9 S-curve for enhancing contrastFig. 5.9 S-curve for enhancing contrast

Page 25: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

Pixel Group ProcessingPixel Group Processing Computing each pixel’s new value as Computing each pixel’s new value as

a function of old value and a function of old value and neighboring pixelsneighboring pixels

Original Image

Convolutionmask

Newimage

Convolutionkernel

* = ( ) i ( ) i

Page 26: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

Pixel Group ProcessingPixel Group Processing

Originalimage

Convolutionmask

Newimage

a b c

d

h

e f

g i

p(x,y)

p’ = apx-1,y+1 + bpx,y+1 + cpx+1,y+1

+ dpx-1,y + epx,y + fpx+1,y

+ gpx-1,y-1 + hpx,y-1 + ipx+1,y-1

p’

Page 27: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

FilterFilter BlurBlur

FilterFilter

ex. ex.

In signal processing, smoothing effect is In signal processing, smoothing effect is obtained by filtering out high frequencies (low obtained by filtering out high frequencies (low pass filter)pass filter)

1/9 1/9 1/91/9 1/9 1/91/9 1/9 1/9

117 117 27 27117 117 27 27117 117 27 27117 117 27 27117 117 27 27

1/9 1/9 1/91/9 1/9 1/91/9 1/9 1/9

*

117 117 27 27117 105 57 27117 105 57 27117 105 57 27117 117 27 27

Page 28: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

FilterFilter Gaussian blurGaussian blur

Gaussian bell curveGaussian bell curve Roughly 70% contribution to the centre Roughly 70% contribution to the centre

pixelpixel SharpenSharpen

FilterFilter

ex.ex.

-1 -1 -1-1 9 -1-1 -1 -1

117 117 51 27 27117 117 51 27 27117 117 51 27 27117 117 51 27 27117 117 51 27 27

117 117 51 27 27117 317 -45 -45 27117 317 -45 -45 27117 317 -45 -45 27117 117 51 27 27

-1 -1 -1-1 9 -1-1 -1 -1

*

Page 29: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

FilterFilter Unsharp maskingUnsharp masking

Accentuate the edges, but retain the otheAccentuate the edges, but retain the other partsr parts

IdeaIdea Blurring filters out high frequenciesBlurring filters out high frequencies If remove blurred image away from origin, it lIf remove blurred image away from origin, it l

eft high frequencies – the sharp edgeseft high frequencies – the sharp edges StepStep

Copy original image, applying a Gaussian bluCopy original image, applying a Gaussian blur to itr to it

Subtracting the blurred mask pixel value froSubtracting the blurred mask pixel value from original pixel value with scaling factorm original pixel value with scaling factor

Page 30: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

origin blur

sharp Unsharp mask(Produced by Photoshop)

Page 31: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

FilterFilter

Image Iblur

Image I’ Image I’’sharp

Image Iblur

Image I’ Image I’’sharp

Is I = I’’ ?

Page 32: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

Geometrical Geometrical TransformationsTransformations

Scaling, translation, reflection, Scaling, translation, reflection, rotation and shearingrotation and shearing

Two transformation schemesTwo transformation schemes Forward mappingForward mapping

Assign original pixel value to transformed Assign original pixel value to transformed pixelpixel

Inverse mappingInverse mapping For each transformed pixel, find its For each transformed pixel, find its

inverse pixel value in original imageinverse pixel value in original image AdvantageAdvantage

No missing pixelsNo missing pixels DisadvantageDisadvantage

Require inverse mappingRequire inverse mapping

Page 33: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

Sampling Methods of Sampling Methods of Inverse MappingInverse Mapping

P1 P2

P3 P4

If transformed pixel ‘X’ locates amongP1, P2, P3 and P4

Nearest neighbor method: I(‘X’) = I(P3 ) where I(p) is the intensity value of pixel p

Bi-linear interpolation: I(‘X’) = (1-a)(1-b)I( P1 ) + a(1-b)I(P2 ) + (1-a)bI(P3 ) + abI(P4 )

where a, b are the fractional parts of ‘X’

Bi-cubic interpolation: based on cubic splines

Page 34: Chapter 5 Bitmapped Images Multimedia Systems. Key Points For displayed images, physical dimension = pixel dimension/device resolution. For displayed

Original image * 2

Bi-linear interpolation

Bi-cubic interpolation