Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture Two Compression & File Specification Standards.

Similar presentations


Presentation on theme: "Lecture Two Compression & File Specification Standards."— Presentation transcript:

1 Lecture Two Compression & File Specification Standards

2 2 Last week We looked at: –Raster and vector graphics –Implications for multimedia Use of colour Image size

3 3 Overview By the end of this lecture you will be familiar with: Compression standards –Lossy –Lossless File specification standards –Main types used in multimedia –Where and when best used

4 4 Image Storage/Retrieval  Fundamental requirement of graphics system software –basic operation: saving the values contained in the frame buffer directly to file note: colour table values may also have to be stored –512x512x8-bit image requires 256kbytes –animated sequences may require 25-50 such frames of data per second

5 5 Image Compression/Coding  To decrease the amount of storage space required –Lossy techniques (e.g. JPEG) apply some filter function to the image which reduces the quantity of data, but cannot reproduce the original image –Lossless techniques (e.g. BMP’s RLE, TIFF’s LZW) Lossless refers to compression schemes that conserve space on disk without sacrificing any data in the image original image is always reproduced Slows down the open and save operations

6 6 Lossless technique: Run-Length Encoding  Uses principle of scanline coherence –if one pixel on a scanline is of a certain colour, the next is likely to be of the same colour –store scanline data as (colour, number) pairs, where number counts the consecutive pixels of the same colour –storage requirements increase as run lengths get smaller

7 7 Example An image consists of 8x8 pixels........

8 8 4 bits/pixel WW W W G B R R WW W W R R R R WW W W G B R R WW W W R R G G WR R G B B R R RR R B B B B B BB R R G B G G BB R R R R G G 8x8 image x 4 bits/pixel = 256 bits

9 9 Run Encoding W4G1B1R2 W4R4 W4G1B1R2 W4R2G2 W1R2G1B2R2 R3B5 B2R2G1B1G2 B2R4G2 28 runs @ 4 bits (colour)+ 3 bits (number) = 196 bits

10 10 Quadtree Encoding Uses principle of pixel coherence –2D variation on scanline coherence –image is recursively subdivided (quartered) into homogenous areas (areas of constant colour) –image is stored as a tree structure where root node represents the entire image leaf nodes represent regions of constant colour non-leaf nodes each have 4 children representing the area subdivision

11 11 Example WW W W G B R R WW W W R R R R WW W W G B R R WW W W R R G G WR R G B B R R RR R B B B B B BB R R G B G G BB R R R R G G 8x8 image, 4 bits/pixel = 256 bits

12 12 Quadtree Encoding W -1 -1 -1 -1 R -1 -1 -1 -1 B R B -1 -1 G G B R R G B R R R R G G W R R R R G R B R R B B G B R R 45 nodes @ 5 bits = 225 bits

13 13 Compression Ratios Definition: CR=Uncompressed image size Compressed image size In previous examples: Run-length CR=256/196= 1.3 Quadtree CR=256/225= 1.14

14 14 Discrete Cosine Transform (DCT)

15 15 JPEG Compression Pixel blockingDCTQuantisationRLE Huffman coding Data packing

16 File Specification Standards

17 17 Standards - Why Bother? Portability –platform independence –programmer portability Not tied to proprietary formats –cost –availability Problem of plethora of standards –e.g. Photoshop supports more than 20 file formats

18 18 Common image file formats BMPrasterwidely usedBMP - Windows Bitmap is native format for Microsoft’s Paint - Supports lossless compression using RLE (Run-Length Encoding) - Images with up to 16 million colours GIF rasterInternet useGIF - CompuServe’s GIF (Graphics Interchange Format) - Means of compressing files for quick transfer over modem - Supports lossless compression using LZW (Lempel-Ziv-Welch) - Images limited to only 256 colours

19 19 Common image file formats cont… JPEGrastercompressedJPEG - Format named after the people who designed JPEG (Joint Photographic Expert Group) - Lossy compression scheme i.e. scarifies image quality to conserve space on disk – Data lossess can be controlled in Photoshop - Evaluates image in 8  8-pixel blocks using ADCT (Adaptive Discrete Cosine Transform) - Best use for photographs PNGrasterinternet usePNG - Introduced to replace.gif - Has a number of advantages over.gif

20 20 Common image file formats cont… TIFFrasterlarge standard - Aldus in early days of Mac to standardise the growing population of scanned images developed TIFF (Tagged Image File Format) - Widely used format both in Mac and PC platforms - Uses lossess compression techniques such as LZW, ZIP as well as lossy technique such JPEG. SWFvector Used by FlashSWF -vector graphics standard used to create animations for the web WMF / CGMvectorspecialist use

21 21 Common video file formats MPEG / MPG / MPV AVI MOV - QuickTime™ many other proprietary formats - e.g. Cinepak®, Intel Indeo®

22 22 Common audio file formats WAVsampled analogue sound AIFF AU MIDIrecords keys / instruments / time MP2 / MP3audio track from MPEG RA / RAMRealAudio streaming technology

23 23 The BMP file format Basic need to store pixel values - but what do they mean? Colour Look-up Table (CLUT) Pixel Value RGB Value Output Device

24 24 Elements of the file specification Initial identifier: BM Size of the file - allows for quick check Offset through the header to the pixel data Width & height of the bitmap, in pixels Number of bits per pixel Type of compression in use (if any) Pixels / metre in ‘x’ and ‘y’ dimensions

25 25 More elements Number of colours in the CLUT Number of important colours CLUT + pixel data follows Questions Why is each element included? Are there any limitations to a BMP?

26 26 Image & Video Coding Standards JPEG (Joint Photographic Experts Group) MPEG (Motion Picture Experts Group) –MPEG I used by the Video CD standard –MPEG II in wide use, digital TV broadcast and DVDs –MPEG IV for multimedia, MPEG VII for description –MPEG-21 for multimedia framework, started June '00

27 27 An MPEG Example

28 28 Video Coding - MPEG I-pictures (intra-coded picture) –used at the start and at cut frames P-pictures (predictive coded picture) –block(s) within the picture reference the previous picture B-pictures (bi-directional predictive coded pictures) –require info from the previous and next pictures in order to draw themselves

29 29 An MPEG Example

30 Video & Video Encoding

31 31 Video on Demand Theoretically requires huge bandwidth, but… Start the same movie every x minutes (BSkyB) Change the frame-rate to make movie fit slot –airline favourite Can allow viewer to pause and resume viewing Future trend for cable & satellite

32 32 What is video? Flick books are a sequence of still images Cine-film is a sequence of still images (frames) –objects are moved slightly between frames –when shown in rapid succession => movement Cine-film shot at 24 fps (frames per second) –projected at 48 fps to reduce flicker close to screen Video is a digital version of cine-film at ~25Hz

33 33 Frame Rate Number of images recorded per second Easy to reduce frame rate for playback Can ‘get away with’ 12 fps (poorer quality) –depends on the speed of the action in the video Lower frame rates often used for video conferencing Trade off in the use of bandwidth

34 34 Bandwidth A measure of the capacity of a communications channel Typical values: –56kbps (bits per second) for modern modem –64kbps for single ISDN channel (128k for ISDN2) –384kbps for 6 ISDN channels (video conferencing) –need ISDN30 to reach MegaStream link (c. 2Mbps)

35 35 Example 1 56kbps modem connection 25Hz frame rate => 56/25 = 2.24kb per frame Assume 8-bit colour depth => 2.24/8 = 280 pels Image size of about 20x14 pixels (useless!) [More typical is 192x144 pixels (8-bit depth) at frame rate of 8 fps using compression of ~30:1 to fit the bandwidth.]

36 36 Example 2 ISDN6 offers 384kbps. How might this be used in video conferencing? Full duplex => 384 / 2 = 192kbps each way OPTION 1:350x260 @ 8fps (30:1, 8-bit pels) OPTION 2:192x144 @ 25fps (29:1, 8-bit pels) Exercise:Assuming same conditions, what bandwidth would be required to support full-screen conferencing at 25fps?

37 37 Example 3 An AVI file is 1.9MB in size. How long will it take to download this over a 56kbps modem? 56kbps = 56,000 bits per second 1.9MB = 1.9 * 1024 * 1024 * 8 = 15,938,355 b Time = 15938355 / 56000 = 285 s (4m 45s) (Assumes perfect connection and full bandwidth.)

38 38 Video Encoding PAL - UK television standard –768 x 576 resolution (much less in practice), 25fps NTSC - US television standard –640 x 480 resolution (again, less when in use) 29fps SECAM – France and eastern europe, far east –768 x 576 resolution (again, less when in use) 25fps

39 39 Frame grabber Card of electronics required for direct input of video into a computer system ‘Grabs’ an image of a set resolution at a set frame-rate, e.g. 192x144 at 15Hz Stores the image in digital form on hard disk Compression or other encoding up to software Match of framegrabber and camera required

40 40 Review Image compression techniques –Lossy and lossless –Run length encoding & Quadtree Common Image standards MPEG Video on demand


Download ppt "Lecture Two Compression & File Specification Standards."

Similar presentations


Ads by Google