school of computer science & information technology g6dpmm - lecture 4 graphics & still...

31
chool of Computer Science & Information Technology G6DPMM - Lecture 4 G6DPMM - Lecture 4 Graphics & Still Image Graphics & Still Image Representation Representation

Upload: wilfred-webster

Post on 25-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

School of Computer Science & Information Technology

School of Computer Science & Information Technology

G6DPMM - Lecture 4G6DPMM - Lecture 4

Graphics & Still Image RepresentationGraphics & Still Image Representation

Page 2: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

Analogue vs DigitalAnalogue vs Digital Analogue informationAnalogue information

Continuously variable signalContinuously variable signal Physical phenomenaPhysical phenomena

Sound/light/temperature/position/pressureSound/light/temperature/position/pressure WaveformWaveform

Electromagnetic (e.g. light)Electromagnetic (e.g. light) Pressure (e.g. sound)Pressure (e.g. sound) Information conveyed by amplitude and frequencyInformation conveyed by amplitude and frequency

Digital informationDigital information Discrete valuesDiscrete values

Smoke signals / Morse code / Binary electronicSmoke signals / Morse code / Binary electronic Sampling of analogue informationSampling of analogue information Analogue to Digital Conversion (A2D) is samplingAnalogue to Digital Conversion (A2D) is sampling

Page 3: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

Analogue MediaAnalogue Media

We see an analogue worldWe see an analogue worldAnalogue image storage technologies:Analogue image storage technologies:

Paint / Chemical film / Photocopier / VideoPaint / Chemical film / Photocopier / Video

Analogue systems all have “noise”Analogue systems all have “noise”Random variations Random variations Hence sequential copies deteriorateHence sequential copies deteriorate

Analogue media is hard to manipulate by Analogue media is hard to manipulate by computercomputerGenerally involves computer-controlled devicesGenerally involves computer-controlled devices

Page 4: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

Digital MediaDigital Media

Digital media is very much easier to Digital media is very much easier to manipulate by softwaremanipulate by software

Digitisation is never perfectDigitisation is never perfectA2D Sampling is an approximationA2D Sampling is an approximationQuality is dependent upon the amount of sampling Quality is dependent upon the amount of sampling

donedone

High quality digital media tends to be largeHigh quality digital media tends to be largeLots of bits needed to store samples!Lots of bits needed to store samples!

Compression is a major issueCompression is a major issue

Page 5: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

Types of Graphics

Computer graphics fall into two categories:Computer graphics fall into two categories: Vector GraphicsVector Graphics

Used for computer generated images, line Used for computer generated images, line drawings, cartoons etc.drawings, cartoons etc.

Bitmap (Raster) Graphics Bitmap (Raster) Graphics Used for photographsUsed for photographs

Page 6: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

Vector Graphics

Mathematical definitions of linesMathematical definitions of lines ScaleableScaleable Not suitable for photographsNot suitable for photographs ExamplesExamples

PostcriptPostcript CGMCGM WMFWMF HPGLHPGL DXFDXF

Edited using “drawing” softwareEdited using “drawing” software

Page 7: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

Bitmap Graphics

Matrix of ‘pixels’Matrix of ‘pixels’ Difficult to re-sizeDifficult to re-size Suitable for photographsSuitable for photographs

ExamplesExamples BMP (DIB)BMP (DIB) GIFGIF PCXPCX TIFFTIFF TARGATARGA JPEGJPEG PNGPNG

Edited using painting software (eg Photoshop)Edited using painting software (eg Photoshop)

Page 8: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

Bitmap Graphics

1 1 1 0 0 00 0 01 1 1 0 0 00 0 00 1 0 0 0 00 0 01 1 1 0 0 00 0 00 1 0 1 0 00 0 10 1 0 1 0 00 0 10 1 0 1 0 00 0 10 1 0 0 0 00 0 01 0 1 0 0 00 0 0

1 1 1 0 0 00 0 0

1 0 1 0 0 00 0 01 0 1 0 0 00 0 01 0 1 0 0 00 0 0

0 0 0 0 0 00 0 0

0 0 0 0 0 00 0 0

Page 9: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

Colour DepthBits per Pixel No. Colours

1 22 33 84 165 326 647 1288 2569 512

10 1,02411 2,04812 2,09613 8,19214 16,38415 32,76816 65,536...24 16,777,216

Page 10: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

Colour Depth

ColourDepth

MaximumColours

DemonstrationFile

1-bit 2 38.46 Kb4-bit 16 153.72 Kb8-bit 256 308.28 Kb

16-bit 65,536 615.5 Kb24-bit 16,777,216 921.65 Kb

Page 11: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

Colourmapping

8-bit colour depth - pixels contain a reference to a 8-bit colour depth - pixels contain a reference to a “palette” (ie 24-bit values)“palette” (ie 24-bit values)

High quality 8-bit (256 colour) imagesHigh quality 8-bit (256 colour) images 16-bit colourmapping (32,768 colours)16-bit colourmapping (32,768 colours) Reasons for colourmappingReasons for colourmapping

Hardware may require itHardware may require it Some software manipulation requires itSome software manipulation requires it Some compression techniques require itSome compression techniques require it

Optimised vs System paletteOptimised vs System palette Display Mode and Palette FlashingDisplay Mode and Palette Flashing

Page 12: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

Vector / Bitmap Conversion

Vectors Vectors BitmapBitmap EasyEasy Perfect representation - scaling issuePerfect representation - scaling issue

Bitmap Bitmap VectorVector Much harder - Much harder - autotraceautotrace Poor qualityPoor quality Highly lossyHighly lossy

Page 13: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

The Need for CompressionThe Need for Compression Graphics tend to be big!Graphics tend to be big! Consider the following:Consider the following:

1024x768 24-bit image1024x768 24-bit image 1024 x 768 = 786,432 pixels1024 x 768 = 786,432 pixels 786,432 x 24 bits = 18,874,368 (c. 18.4 Mb)786,432 x 24 bits = 18,874,368 (c. 18.4 Mb)

Approximately 40 images per 750 Mb CD-ROM!Approximately 40 images per 750 Mb CD-ROM!

Data compression is essentialData compression is essential

Page 14: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

Image CompressionImage Compression

Lossless CompressionLossless Compression Decompressed image is a perfect copy of the originalDecompressed image is a perfect copy of the original Example File Format: GIFExample File Format: GIF

Lossy CompressionLossy Compression Decompressed image is an imperfect approximation Decompressed image is an imperfect approximation

of the originalof the original Example File Format: JPEGExample File Format: JPEG

Page 15: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

Lossless AlgorithmsLossless Algorithms Run Length EncodingRun Length Encoding

Sequences of “runs” of repeated data is replaced by a single data item, and Sequences of “runs” of repeated data is replaced by a single data item, and the length of the run.the length of the run.

Used by TIFF, DIB/BMPUsed by TIFF, DIB/BMP

LZ77LZ77 Lempel-Ziv substitutional compression (1977)Lempel-Ziv substitutional compression (1977) Keeps track of a “window” of data – if repetition is seen it replaces this with Keeps track of a “window” of data – if repetition is seen it replaces this with

a reference.a reference. Many applications – including Huffman (LZH) and ZipMany applications – including Huffman (LZH) and Zip

LZW (Lempel-Ziv-Welch)LZW (Lempel-Ziv-Welch) Derived from LZ77Derived from LZ77 Developed (and patented) by Unisys – licensed for CompuserveDeveloped (and patented) by Unisys – licensed for Compuserve Used by GIFUsed by GIF

DeflateDeflate Derived from LZ77Derived from LZ77 Used by PNGUsed by PNG

Page 16: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

Lossy AlgorithmsLossy Algorithms Common algorithms all operate on the waveformCommon algorithms all operate on the waveform Fourier TransformFourier Transform

A technique for expressing a waveform as a weighted series of A technique for expressing a waveform as a weighted series of sines and cosinessines and cosines

DCT (Discrete Cosine Transform)DCT (Discrete Cosine Transform) A type of Fourier transformA type of Fourier transform Waveform is expressed as a weighted sum of cosinesWaveform is expressed as a weighted sum of cosines Used by JPEGUsed by JPEG

WaveletsWavelets An alternative to Fourier transformAn alternative to Fourier transform Signals converted into a series of rough-edged waveletsSignals converted into a series of rough-edged wavelets Mostly used for specialised purposes (e.g. for fingerprints)Mostly used for specialised purposes (e.g. for fingerprints)

Fractal CompressionFractal Compression Fractal theoryFractal theory Not (currently) widely usedNot (currently) widely used

Page 17: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

JPEG Compression

Original Image - 285 K

Page 18: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

JPEG Compression

50% Compression - 15 K

Page 19: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

JPEG Compression

70% Compression - 10.8 K

Page 20: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

JPEG Compression

90% Compression - 6.9 K

Page 21: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

JPEG Compression

95% Compression - 5.3 K

Page 22: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

JPEG Compression

99% Compression - 2.6 K

Page 23: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

Image File Formats

Vendor Defined FormatsVendor Defined FormatsOS Vendors (eg Microsoft / Apple)OS Vendors (eg Microsoft / Apple)Application Vendors (eg Adobe)Application Vendors (eg Adobe)May be open, (ie published specifications) or closed May be open, (ie published specifications) or closed

(protected by IPR)(protected by IPR)

Vendor Neutral FormatsVendor Neutral FormatsUsually defined by standards organisationsUsually defined by standards organisations

Page 24: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

Apple Macintosh Formats

PICTPICT Very versatileVery versatile May contain bitmap and vector graphics, and May contain bitmap and vector graphics, and

metadata.metadata. May be compressed or uncompressed using May be compressed or uncompressed using

various algorithms.various algorithms. Can be ported to other platforms, but some Can be ported to other platforms, but some

features usually lost.features usually lost. Now rarely used – even on Macintosh!Now rarely used – even on Macintosh!

Page 25: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

Windows Formats

Microsoft DIB (Device Independent Bitmap)Microsoft DIB (Device Independent Bitmap) .BMP .DIB .RLE.BMP .DIB .RLE 1, 8 or 24 bit bitmap - optional RLE compression1, 8 or 24 bit bitmap - optional RLE compression

Microsoft PAL (Palette)Microsoft PAL (Palette) Palette for 8 bit imagesPalette for 8 bit images

Microsoft RIFF Microsoft RIFF (Resource Interchange File Format)(Resource Interchange File Format) Embedded DIBEmbedded DIB Other media typesOther media types

Windows Metafiles (WMF)Windows Metafiles (WMF) Usually used for vectors, but can contain almost anything!Usually used for vectors, but can contain almost anything!

Page 26: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

Adobe Formats

Photoshop PDFPhotoshop PDF Bitmap format (mostly)Bitmap format (mostly) UncompressedUncompressed Supports various colour modelsSupports various colour models Supports all features of Photoshop (eg layers, channels etc).Supports all features of Photoshop (eg layers, channels etc). Version issuesVersion issues

PostcriptPostcript Page description language for printersPage description language for printers Encapsulated postcript (EPF)Encapsulated postcript (EPF) Primarily used for Vectors, but can contain embedded bitmaps.Primarily used for Vectors, but can contain embedded bitmaps.

Page 27: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

Truevision Targa

Truevision - graphics hardware & software companyTruevision - graphics hardware & software company Targa (TGA)Targa (TGA)

Bitmap (1 to 32 bits), with optional RLEBitmap (1 to 32 bits), with optional RLE Multiple images (eg different resolutions)Multiple images (eg different resolutions) MetadataMetadata Advanced features (eg alpha channels and gamma values)Advanced features (eg alpha channels and gamma values) Developer definable dataDeveloper definable data

Very widely used for storage of high quality Very widely used for storage of high quality (24 or 32 bit) images. (24 or 32 bit) images.

Page 28: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

Aldus/Adobe TIFF

TIFF (.TIF) Tag Image File FormatTIFF (.TIF) Tag Image File Format Formerly Aldus - now maintained by Formerly Aldus - now maintained by

AdobeAdobe 24 bit bitmap format24 bit bitmap format Supports a wide range of compression Supports a wide range of compression

algorithms (including RLE, LZW, JPEG algorithms (including RLE, LZW, JPEG and many others)and many others)

Extensive metadata capability Extensive metadata capability

Page 29: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

CompuServe GIF

8 bit LZW compressed bitmapSupports transparencySupports multiple images & animationWidely used on WWW

Licence problemsCompuServe patentUnisys policy

Page 30: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

PNGPortable Network GraphicsDesigned to replace GIFSupports greyscale, colourmapped or

truecolour images (up to 48 bit!)Supports alpha channels and gamma

correctionLossless CRC-32 compressionNo multiple image supportNo patent problems!

Page 31: School of Computer Science & Information Technology G6DPMM - Lecture 4 Graphics & Still Image Representation

JPEG

Joint Picture Expert GroupJoint Picture Expert Group Both an algorithm and a file format!Both an algorithm and a file format! Lossy Truecolour compression (DCT)Lossy Truecolour compression (DCT)