room allocations: mlt1: a - j plt1: k - r eng1401: s – z ......4/2/2004 compsci 111 s1c - lecture...

Post on 24-Sep-2020

6 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

4/2/2004 COMPSCI 111 S1c - Lecture 14 1

The Test, be there or fail…The Test, be there or fail…

Test is on 6th April and begins at 6:30pm.

Room allocations:MLT1: A - JPLT1: K - REng1401: S – Z

Get there by 6:20pm!

4/2/2004 COMPSCI 111 S1c - Lecture 14 2

Friday’s lecture is a revision lecture for the test…

4/2/2004 COMPSCI 111 S1c - Lecture 14 3

There is no lab next week

You still need to hand in this week’s lab as per usual

No excuses

4/2/2004 COMPSCI 111 S1c - Lecture 14 4

Bitmap and Vector Graphics

Drawing and Painting Applications

4/2/2004 COMPSCI 111 S1c - Lecture 14 5

Bitmap GraphicsBitmap Graphics

Storing pictures digitally• Sample the image (divide into dots)• Image resolution (number of dots)• The visual size of the image is not related to resolution:

200 x 250 40 x 50 20 x 25

4/2/2004 COMPSCI 111 S1c - Lecture 14 6

Black and White picturesBlack and White pictures

Digital Pictures consist of small dots• Each dot is called a picture element (pixel)

Storing information• Black and White are only two states• Use bits to represent pixels (0 = OFF, 1 = ON)• One to one mapping, so known as Bitmap

1 1 1 1

1 0 0 1 11111001100111111 1

1 1 1

0 0

1

4/2/2004 COMPSCI 111 S1c - Lecture 14 7

Black and White PicturesBlack and White Pictures

Halftone screening• patterns of black and white appear gray

Halftone screeningClosest Color

4/2/2004 COMPSCI 111 S1c - Lecture 14 8

Colour BitmapsColour Bitmaps

Colours• Use more than 1 bit per pixel• Imagine each bit on own plane• Number of planes = depth of colour in image• Combine the bit planes to form binary number• Map the binary number to a colour

0 0 1 10 0 0 11 0 1 11 1 1 0

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

1 0 1 10 1 0 11 1 1 11 0 1 0

1 0 1 11 0 0 11 0 0 10 1 1 1

Image composed of 4 bitplanes

1100 0010 1111 11111010 0101 0010 11111000 0111 0000 11010110 1111 1110 1010

Each pixel uses 4 bits

4/2/2004 COMPSCI 111 S1c - Lecture 14 9

How much memory is required?How much memory is required?

One binary number used for each pixel• 1 bit 2 colours• 2 bits 4 colours• 4 bits 16 colour• 8 bits 256 colours• 16 bits 65536 colours• 24 bits 16,777,216 colours

How many bits are required for a 16 colour image 100 pixels wide x 8 pixels high?• 100x8x4 = 3200 bits = 400 bytes

An image using 24 bit colour, 1024 wide x 1024 high?• 3 MB

4/2/2004 COMPSCI 111 S1c - Lecture 14 10

Displaying ImagesDisplaying Images

Image Size• Pixels are used to represent the image• Size of each pixel depends on physical device

– Screen 72 dots per inch (dpi)– Laser Printer 300, 600 or even 1200 dpi

Printer Screen

1 1 1 11 1 1 01 1 0 01 0 0 0

Bitmap

4/2/2004 COMPSCI 111 S1c - Lecture 14 11

Printing BitmapsPrinting Bitmaps

Printer and Screen use different sized dots• We want the image to be the same physical size (WYSIWYG)• Scale the bitmap

From low to high resolution

From high to low resolution

4/2/2004 COMPSCI 111 S1c - Lecture 14 12

Compressing ImagesCompressing Images

ETDD: 522 - 526

Simply reducing number of colours

Image is 200 pixels wide, 200 pixels high= 40,000 pixels

31,942 colours75 KB

256 colours40 KB

16 colours20 KB

4/2/2004 COMPSCI 111 S1c - Lecture 14 13

Compression AlgorithmsCompression Algorithms

Graphics Interchange Format (GIF)• Lossless method• 256 colours• Records repetition in image• Good for graphics, poor for photos

Image Size: 200x100Original (256 colours): 20KBGIF (256 colours): 3KB

Image Size: 200x200Original (256 colours): 40KBGIF (256 colours): 32KB

4/2/2004 COMPSCI 111 S1c - Lecture 14 14

Compression Algorithms - JPEGCompression Algorithms - JPEG

Joint Photographic Experts Group (JPEG)• Lossy method• 16 Million colours (24 bit)• Averages nearby colours• Different degrees of compression• Good for photos, poor for graphics

Image Size: 200x200Original: 120KBJPEG (50%): 6KB

Image Size: 200x200Original: 120KBJPEG (99%): 2KB

Image Size: 200x100Original: 60KBJPEG (50%): 5KB

4/2/2004 COMPSCI 111 S1c - Lecture 14 15

Vector GraphicsVector Graphics

Object-oriented graphics• Objects created independently • Defined by mathematical formulae

Example• Object Type: Square• Height: 100• Width: 100• Position_X: 354• Position_Y: 289• Outline Width: 4 pt• Fill Colour: Light Blue

4/2/2004 COMPSCI 111 S1c - Lecture 14 16

Drawing ToolsDrawing Tools

Make sure that the tools are displayed• View Toolbars (Drawing)

Using a Grid• Invisible/ Visible• Helps align objects

4/2/2004 COMPSCI 111 S1c - Lecture 14 17

PalettesPalettes

Palettes• Used to change the way objects are drawn

Fill Palette• Colour inside the object

Line (Pen) Palette• Outline of object

Text Palette• Colour of text

4/2/2004 COMPSCI 111 S1c - Lecture 14 18

Working with ObjectsWorking with Objects

Selecting Objects• Click to select• Handles appear on selected objects

Selecting Multiple Objects• Hold SHIFT key down while clicking• Drag a selection rectangle

Grouping Objects• Keeps objects together• Change all objects at once• Select objects then choose Group

Not Selected Selected

4/2/2004 COMPSCI 111 S1c - Lecture 14 19

Working with ObjectsWorking with Objects

Layers• Each objects exists in own layer• Arrange order of objects• Select object, and Send Backward

Text Boxes/ Text Frame• Used to create “floating text”• Click inside box to alter text• Click on outline to alter box

4/2/2004 COMPSCI 111 S1c - Lecture 14 20

PropertiesProperties

Double-click on object

4/2/2004 COMPSCI 111 S1c - Lecture 14 21

Editing and Creating Bitmaps

4/2/2004 COMPSCI 111 S1c - Lecture 14 22

Image ProcessingImage Processing

Manipulation of an existing image

Bitmap Images• Changes pixels in some way

Uses• Colouring satellite images• Correcting photographs• Computer Vision• Matching Faces / Fingerprints

4/2/2004 COMPSCI 111 S1c - Lecture 14 23

Global FilteringGlobal Filtering

Brightness

Hue-Shifting Solarize

Contrast Posterize

4/2/2004 COMPSCI 111 S1c - Lecture 14 24

Local FilteringLocal Filtering

Edge DetectionNoise

OriginalBlur Sharpen

4/2/2004 COMPSCI 111 S1c - Lecture 14 25

Other ModificationsOther Modifications

Applying a mask• Selecting a portion of the

image

Painting• Airbrushing

Cloning• Copying part of the image

Digital Warping / Morphing• Warping the image

4/2/2004 COMPSCI 111 S1c - Lecture 14 26

CloningCloning

Copying piece of the original image

Cloned part of this image

to form this image

4/2/2004 COMPSCI 111 S1c - Lecture 14 27

KeithKeith

Is anything wrong with this picture?

Has anything been altered?

4/2/2004 COMPSCI 111 S1c - Lecture 14 28

Keith's familyKeith's family

What about this picture?

Does anything look unusual?

4/2/2004 COMPSCI 111 S1c - Lecture 14 29

The original photoThe original photo

4/2/2004 COMPSCI 111 S1c - Lecture 14 30

Keith and his friendsKeith and his friends

4/2/2004 COMPSCI 111 S1c - Lecture 14 31

Warping an ImageWarping an Image

Use a mathematical formula to transform the pixels

4/2/2004 COMPSCI 111 S1c - Lecture 14 32

Other EffectsOther Effects

.

4/2/2004 COMPSCI 111 S1c - Lecture 14 33

Creating Three-Dimensional GraphicsCreating Three-Dimensional Graphics

Uses a model of the object.• Similar to Vector Graphics• Based on objects described mathematically• More accurate models -> more realistic images

2 Dimensional ObjectsCircle

Radius 100Center 20, 45

AppearanceLine Thickness 3Fill Pattern PlainColour Blue

3 Dimensional ObjectsSphere

Radius 100Center 20, 45, 30

AppearanceSurface TextureSurface PigmentSurface Finish

4/2/2004 COMPSCI 111 S1c - Lecture 14 34

Modelling and SimulationModelling and Simulation

Representing objects in three dimensions• Must model properties of light (diffusion, refraction etc.)• Dust, Fog, etc.• Model surface properties of objects

Animation can be automated • Provide laws describing interaction between objects• Realistic animation requires physical laws (gravity, solidity etc.)

Simulation• Requires and internal model, and physical laws• Graphics and Simulation often work hand-in-hand

4/2/2004 COMPSCI 111 S1c - Lecture 14 35

Image RenderingImage Rendering

Drawing an image from an internal model

Scene Description• Only use simple shapes (eg; Sphere, Cylinder, Box)• Complex objects built from simple ones• Each object has properties (eg; colour, texture)

To view the scene• Specify camera position and orientation• Give light sources

4/2/2004 COMPSCI 111 S1c - Lecture 14 36

Methods of Modelling and RenderingMethods of Modelling and Rendering

Modelling• Wire-Frame• Solid Object• Polygon-Surface

Shading• Lambert shading (flat shading)• Gouraud shading• Phong shading

4/2/2004 COMPSCI 111 S1c - Lecture 14 37

Developing a SceneDeveloping a Scene

Orthographic projections•Top View (Plan)•Front View•Side View

Polygon Mesh used to represent objects. Note that spheres and other curved objects are represented with few points

4/2/2004 COMPSCI 111 S1c - Lecture 14 38

Wireframe drawing with perspectiveWireframe drawing with perspective

4/2/2004 COMPSCI 111 S1c - Lecture 14 39

Determining visible linesDetermining visible lines

4/2/2004 COMPSCI 111 S1c - Lecture 14 40

Flat Polygon ShadingFlat Polygon Shading

4/2/2004 COMPSCI 111 S1c - Lecture 14 41

Gouraud ShadingGouraud Shading

4/2/2004 COMPSCI 111 S1c - Lecture 14 42

Phong ShadingPhong Shading

4/2/2004 COMPSCI 111 S1c - Lecture 14 43

Curved SurfacesCurved Surfaces

4/2/2004 COMPSCI 111 S1c - Lecture 14 44

Multiple light sourcesMultiple light sources

4/2/2004 COMPSCI 111 S1c - Lecture 14 45

Texture MappingTexture Mapping

4/2/2004 COMPSCI 111 S1c - Lecture 14 46

ShadowsShadows

4/2/2004 COMPSCI 111 S1c - Lecture 14 47

Reflection Reflection

4/2/2004 COMPSCI 111 S1c - Lecture 14 48

DifficultiesDifficulties

Modelling objects• Irregularity• Texture

Modelling image• Lighting effects• Focus• Simulating effects of human eye/ brain

Mathematical models often simplified• Movement is too regular• Objects are too regular/ smooth• Objects are too clean/ crisp

4/2/2004 COMPSCI 111 S1c - Lecture 14 49

Altering the NormalAltering the Normal

Introducing some irregularity into smooth objects• Bump mapping

4/2/2004 COMPSCI 111 S1c - Lecture 14 50

CoordinatesCoordinates

. Two dimensional+y

-y

+x-x

+y

-y

+x-x

-z

+zThree dimensional

Right handed

+y

-y

+x-x

+z

-z

Left handed

4/2/2004 COMPSCI 111 S1c - Lecture 14 51

Ray TracingRay Tracing

Create 3d model of objects in computer• Position light source, object and camera (eye)• Place a viewing plane (window) in the scene

Draw the image that the camera sees through the window.• Viewing plane maps 1-to-1 onto bitmap image• For each pixel, work out what colour it should be

Trace a ray from the camera through each pixel• If it misses the object, then the pixel is black• If it hits the object, then work out the colour based upon

– surface of object– angle between camera and light source

4/2/2004 COMPSCI 111 S1c - Lecture 14 52

Ray TracingRay Tracing

.

top related