Si23 introduction to computer graphics
1 / 30

SI23 Introduction to Computer Graphics - PowerPoint PPT Presentation

SI23 Introduction to Computer Graphics Lecture 2 - Images Graphics Programming 3D Graphics URL VRML viewer 2D vector graphics surfaces Image Display URL SVG Viewer lines, areas URL GIMP viewing, shading graphics algorithms colour interaction Course Outline OpenGL API

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

Download Presentation

SI23 Introduction to Computer Graphics

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

Si23 introduction to computer graphics l.jpg
SI23Introduction to Computer Graphics

Lecture 2 - Images

Course outline l.jpg








2D vector












viewing, shading





Course Outline




Course outline images and colour l.jpg




Course Outline – Images and Colour

  • Image creation, manipulation and display

  • Colour



Graphics display hardware cathode ray tube l.jpg
Graphics Display Hardware -Cathode Ray Tube

Basic technology for

workstation screens is the

cathode ray tube




heated cathode

electron beam




Beam scans across

screen in series

of lines

- 60 times per second

Colour raster scan display l.jpg




metal mask

Colour Raster Scan Display

  • Colour CRT

Colour composed as

combination of RED, GREEN, BLUE

Colour frame buffers l.jpg

Today most colour displays

have 24bit frame buffers

or pixmaps.

So each pixel has a 24bit

colour value associated

with it - 8 bits for R,G,B.








01101101 11011001 10011100

red gun

green gun

blue gun

Colour Frame Buffers

Colour look up table clut colour palette l.jpg
Colour Look Up Table (CLUT)Colour Palette

To save on memory costs, some displays use a look-up table …

8-bit frame buffer

1 0 1 0 0 1 1 1

Pixel value (=167)










24-bit colour table

11001100 10110110 11011100









red green blue

Pixel value acts as an index into the look up table. This

allows 256 (=28) on-screen colours from a palette of 16.7 million

Gamma correction l.jpg
Gamma Correction

  • For CRT displays, brightness is not a linear function of the drive signal

  • Instead it is related by:

    Brightness = (Signal)g

  • Typical value for g is 2.2

  • Thus displays will provide ‘gamma correction’ of the red, green and blue signals to give the expected uniform effect

Note: assumes signal in range [0,1]

Homework l.jpg

  • How does colour work for LCD displays??

Images l.jpg

We can generate images in a variety of ways…

… and we can subsequently process them in order to …

The GIMP will help us do many of these things

Fill in the answers!


Image formats l.jpg

Large number of formats have emerged over the years


Which are in common use?

Use a couple of test pictures

Image Formats

Silicon graphics rgb format l.jpg
Silicon Graphics RGB Format

  • File begins with a header which has the following information:

    • xsize, ysize - dimensions of image

    • zsize : 1 for 8-bit (colour index); 3 for 24-bit colour

    • colour map flag: indicates image or colour map

  • The rest of the file contains the data

    • for 8-bit, each pixel represented as 1 byte, so there are ysize scan lines, each of xsize bytes

    • for colour, three single images (for R, G, B) are stored, one after the other.

Image sizes l.jpg

The picture of Bank’s Peninsula is 2472 by 1704 pixels

as RGB image it is 12 Mbytes

The diagram with the square is 256 by 256 pixels

As RGB image it is 193k bytes

Image Sizes

Compression rle l.jpg
Compression - RLE

Consider the triangle

on right.

Suppose 0 represents

black and 1 represents


The image file will look like, for each scan line:


It would be more efficient to store as ‘runs’ of pixel values:


This is known as Run Length Encoding (RLE)

and is an option in the RGB image file specification.

Rle compression l.jpg

The NZ photo reduces from 12 Mbytes to 9.5 with RLE compression

Is this what you’d expect?

The square reduces from 193k to 13k with RLE compression

Is this what you’d expect?

RLE Compression

Image formats16 l.jpg
Image Formats compression

  • RGB is one of a large number of image formats

    • MS Windows bitmap for PC applications (BMP format)

    • GIF, JPEG, PNG are widely used across different platforms

  • RLE is just one of a number of compression techniques - different formats use different compression methods

Image formats gif l.jpg
Image Formats - GIF compression

  • GIF (Graphics Interchange Format)

    • probably the most common image format

    • developed by CompuServe Inc

    • 8 bit colour indices point to entries in a colour table of size 256

    • thus in uncompressed form, we have header comprising colour table, followed by rows of data, one byte per pixel

    • rows stored as 0,8,16,..; 4,12,20,..; 2,6,10,..; 1,3,5,... this interlacing gives progressive image display

    • 24 bit colour images not supported

    • Animated GIFs a very useful feature (used with care)

Lzw compression l.jpg
LZW Compression compression

  • GIF uses the LZW (Lempel-Ziv-Welch) compression technique which has been subject of frequent legal battles -UNISYS and CompuServe claim to have patented it (so not supported fully in Windows GIMP)

  • Dictionary-based

    • frequently occurring patterns of data are identified and given code words which are shorter than the original pattern

  • For normal images, typically better than RLE; not good on noisy images (neither is RLE)

  • For file size comparison, see PNG later

Image formats png l.jpg

PNG = Portable Network Graphics compression

Created as a successor to GIF, free of legal restrictions

Defined as a Web standard by W3C

.. And better than GIFs!

Key features:


Gamma correction





Image Formats - PNG

Png features l.jpg

Transparency compression

Alpha channel in addition to RGB

Gamma Correction

Store the gamma value at creation

Correct at display time

Can you work out the correction formula?

PNG Features

Png features21 l.jpg

Text compression

Why would it be useful to associate text with an image?


2d interlacing

7 passes (Adam7)

Why is this useful?

PNG Features

Png features22 l.jpg

Filtering compression

Simple operator to promote good compression

Eg sub filter replaces pixel values on scan line, with differences from predecessor


Uses LZ77 approach (recall from SI11)

Plus Huffman encoding (also from SI11)

Used in gzip

PNG Features

Encoding is: interlace, filter, compress

Example l.jpg

NZ photo does not compress particularly well compression

Uncompressed 12 MB

RLE 9.5 MB


Square compresses outstandingly well

Uncompressed 193 kB

RLE 13 kB

PNG 1 kB


Image formats jpeg file interchange format jfif l.jpg
Image Formats - JPEG File Interchange Format (JFIF) compression

  • Developed as an international standard interchange format using a compression method developed by Joint Photographic Experts Group (JPEG)

  • Supports 24 bit colour, or greyscale – but not palette

  • Copes with noisy data, so can handle scanned images

Jpeg compression l.jpg
JPEG Compression compression

  • Discrete Cosine Transform (DCT) applied to 8x8 subblocks of image

    • DCT transforms data values to a new set of 64 data items (in a frequency space)

    • ordered in importance (1st value represents average over subblock, etc, values at end represent high frequency, ie noise)

    • ‘safe’ to discard these noise terms and store only the early terms from the DCT

Jpeg compression26 l.jpg
JPEG Compression compression

  • Resulting values are then compressed using Huffman encoding

  • Free of any legal problems

  • Known as lossy compression, because we cannot recreate exact original image (cf RLE and LZW which are lossless)

Jpeg quality control l.jpg
JPEG Quality Control compression

  • JPEG allows user to tune the quality of encoding by a ‘quality setting’

    • corresponds to ignoring values in the DCT

    • Q-factor from 0 to 100 (100 = high quality)

  • Suggested technique:

    • encode using Q factor of 75%, decode and redisplay

    • if defects seen, increase Q and re-encode

    • if acceptable, decrease Q until just acceptable

Example28 l.jpg

For the NZ photograph, we have outstanding compression compression

Uncompressed 12MB


JPEG 339kB


Image transfer across www summary l.jpg
Image Transfer across WWW compression- Summary

  • GIF format still predominates 

    • lossless, 8-bit palette-based, LZW compression, legal status in doubt, supported by all browsers

  • PNG

    • lossless, 8-bit palette or 24 bit colour, non-patented compression, transparency, gamma correction, 2d interlacing, filtering

  • JPEG

    • lossy, 24-bit, non-patented compression

  • Choice:

    • PNG for synthetic images

    • JPEG for photographic images

Reading more l.jpg
Reading More compression

  • The source of PNG information


  • Test your browser support for PNG transparency


  • What is difference between GIF87a and GIF89a?

  • Login