Marc Schra enberger 04.26 - University of Rhode Island

30
24.2 Image Formation Marc Schraffenberger 04.26.04

Transcript of Marc Schra enberger 04.26 - University of Rhode Island

Page 1: Marc Schra enberger 04.26 - University of Rhode Island

24.2 Image Formation

Marc Schraffenberger

04.26.04

Page 2: Marc Schra enberger 04.26 - University of Rhode Island

Outline

• Definitions

• Orthographic Projection

• Perspective Projection

• Vanishing Points

• Scaled Orthographic Projection

• Depth of Field and Lens Systems

• Light and Ray Tracing

• Diffuse Reflection

• Specular Reflection

Page 3: Marc Schra enberger 04.26 - University of Rhode Island

Definitions

Scene

Image Plane

Pixels

Page 4: Marc Schra enberger 04.26 - University of Rhode Island

Example Scene Description

( 2, 5, 5 ) ( −2, 5, 25 )( 0, 5, 15 )

z

x

Page 5: Marc Schra enberger 04.26 - University of Rhode Island

Orthographic Projection

Page 6: Marc Schra enberger 04.26 - University of Rhode Island

Orthographic Projection

• In orthographic projections, parallel lines remain parallel

after the projection.

• Leave (x, y) coordinates the same, but set z = 0

• The transform drops from three to two dimensions,

resulting in no way to retrieve the dropped dimension.

• The red sphere at (2, 5, 5)scene → (2, 5)image.

Page 7: Marc Schra enberger 04.26 - University of Rhode Island

Orthographic Projection

Image plane

y, Y

x, X

Z

Page 8: Marc Schra enberger 04.26 - University of Rhode Island

Perspective Projection

Page 9: Marc Schra enberger 04.26 - University of Rhode Island

Perspective Projection

y

(x, y)

Z

(X, Y, Z)Image plane

f

Lens center

Y

Xx

Page 10: Marc Schra enberger 04.26 - University of Rhode Island

Perspective Projection Equations

• For any point, p, in world space we can project it onto

the image plane, yielding a new point q.

• Derive perspective projection equations by using similar

triangles

qx = −fpx

pz

qy = −fpy

pz

Page 11: Marc Schra enberger 04.26 - University of Rhode Island

Perspective Projection Example

The red sphere is at (2, 5, 5)scene and the camera’s focal

length, f , is 1. We can now use the perspective project

equations to get the image coordinates.

qx = −fpx

pz

= −2

5= −0.4

qy = −fpy

pz

= −5

5= −1.0

Page 12: Marc Schra enberger 04.26 - University of Rhode Island

Perspective Projection Matrix

Typically projections as represented in matrix form. We can

the define the perspective transformation matrix, Pp as

Pp =

1 0 0 0

0 1 0 0

0 0 1 0

0 0 − 1

f0

Page 13: Marc Schra enberger 04.26 - University of Rhode Island

Perspective Projection Matrix Example

Using the perspective transformation matrix we can easily

obtain the image space coordinates of the red sphere.

q = Ppp =

1 0 0 0

0 1 0 0

0 0 1 0

0 0 −1

10

2

5

5

1

=

2

5

5

−5

−0.4

−1.0

−1.0

1.0

The last step divides the entire vector by the w-component to

get a 1 in the last component. (required for homogeneous

coordinates)

Page 14: Marc Schra enberger 04.26 - University of Rhode Island

Vanishing Points

Parallel lines converge to a vanishing point under perspective

projection. To show this, define a line as a set of points

(px + λdx, py + λdy, pz + λdz) which passes through point p

with direction d and λ varying between −∞ and +∞.

The projection of a point from this line onto the image plane

is

(fpx + λdx

pz + λdz

, fpy + λdy

pz + λdz

).

Thus the vanishing point becomes v∞ = (f dx

dz, f

dy

dz), showing

that lines with the same direction have a common vanishing

point.

Page 15: Marc Schra enberger 04.26 - University of Rhode Island

Scaled Orthographic Projection

If an object is shallow compared with its distance from the

camera, we can approximate its perspective projection by

using scaled orthographic projection.

• If the depth points of the object varies in some range

Z0 ± ∆Z, with ∆Z � Z0

• We can set a scaling factor s = fZ0

• The equations for the projection of the scene coordinates

onto the image plane are x = sX and y = sY

Since this is only an approximation, it should only be used

for objects with little depth variation.

Page 16: Marc Schra enberger 04.26 - University of Rhode Island

Perspective Projection

Page 17: Marc Schra enberger 04.26 - University of Rhode Island

Depth of Field

Page 18: Marc Schra enberger 04.26 - University of Rhode Island

Perspective Projection with a Lens

So far our projections have been for non-lens cameras. Once

a lens is introduced, we enable more light to enter the image

plane. Because of this not all objects can be in-focus. If an

object is at distance Z it will be in-focus at a fixed distance

from the lens Z ′ such that

1

Z+

1

Z ′=

1

f

Because of this only a range of depths will be in-focus, which

is called the depth of field.

Page 19: Marc Schra enberger 04.26 - University of Rhode Island

Perspective Projection with a Lens

Also note that since the object’s distance, Z, is typically

much larger then the image distance Z ′ or f . Because of this

we can approximate by

1

Z+

1

Z ′≈

1

Z ′⇒

1

Z ′≈

1

f.

Therefore since Z ′ ≈ f , we can still use perspective projection

with a lens system.

Page 20: Marc Schra enberger 04.26 - University of Rhode Island

Light

• The study of how light interacts with objects is crucial to

image formation. Without light, all images would be

completely dark.

• The intensity of a pixel in an image is proportional to the

amount of light directed at the camera from the surface

of the projecting object.

• The amount of light directed from the surface depends on

the reflectance properties of the surface, the light sources

in the scene, and the reflectance properties of other

objects.

Page 21: Marc Schra enberger 04.26 - University of Rhode Island

Ray Tracing

C

A

B

E

D

F

Page 22: Marc Schra enberger 04.26 - University of Rhode Island

Ray Tracing

A - ray goes directly to camera

B - ray misses everything and goes off to ∞

C - ray bounces off mirror and into the camera

D - ray hits a diffuse surface and generates new rays

E - ray hits a partially transparent surface generates a

transmitted ray and reflected ray

F - ray bounces off mirror and hits a surface that absorbs it

Page 23: Marc Schra enberger 04.26 - University of Rhode Island

Diffuse Reflection

• When light hits a diffuse surface it is absorbed into the

surface

• Depending on the light color and material color, they

may be completely absorbed or scattered in a reflection

direction.

• The probability of the reflection direction is equal for all

directions

• This means it is independent of the camera’s position or

direction

Page 24: Marc Schra enberger 04.26 - University of Rhode Island

Diffuse Reflection

l

p

n

o

Lambert’s Law:

reflected light is deter-

mined by the cosine be-

tween the surface normal n

and the light vector l.

Idiff = (n·l)mdiff⊗sdiff

Page 25: Marc Schra enberger 04.26 - University of Rhode Island

Diffuse Reflection Example

light source = (0.0, 10.0, 10.0)

surface point = (2.0, 5.0, 5.0)

surface point normal = (0.0, 1.0, 6.0)

light color = (0.6, 0.1, 0.3)

material color = (0.5, 0.25, 0.25)

Ip = ((0, .16, .98) · (−.27, .68, .68))(0.5, 0.25, 0.25) ⊗ (0.6, 0.1, 0.3)

= 0.783(0.5, 0.25, 0.25) ⊗ (0.6, 0.1, 0.3)

= (0.2349, 0.0196, 0.0587)

Page 26: Marc Schra enberger 04.26 - University of Rhode Island

Specular Reflection

Page 27: Marc Schra enberger 04.26 - University of Rhode Island

Specular Reflection

• Specular reflection makes a surface look shiny by creating

highlights

• Helps viewer understand curvature of the surface

• It requires knowledge of the view vector, making it view

dependent

Page 28: Marc Schra enberger 04.26 - University of Rhode Island

Specular Reflection

o

l

p

nh

v

The following specular

equation was presented

by Blinn, which calculates

a normalized half vector

between l and v

Ispec = (n · h)mspec

h =l + v

‖l + v‖

Page 29: Marc Schra enberger 04.26 - University of Rhode Island

Summary

• Definitions

• Orthographic Projection

• Perspective Projection

• Vanishing Points

• Scaled Orthographic Projection

• Depth of Field and Lens Systems

• Light and Ray Tracing

• Diffuse Reflection

• Specular Reflection

Page 30: Marc Schra enberger 04.26 - University of Rhode Island

Questions?