מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered...

48
Image Warping

Transcript of מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered...

Page 1: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Image Warping

Page 2: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Image Mapping

Page 3: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Image Mapping - Examples

Page 4: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image
Page 5: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image
Page 6: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Forward Mapping

Page 7: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Forward Mapping

Page 8: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Forward Mapping - Disadvantages

Page 9: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Example – Forward MappingOriginal Rotated

Zoom In

Page 10: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Backward Mapping

𝑓𝑓−1

The Problem:(u,v) are not integers!

Page 11: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Nearest Neighbor

Page 12: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Example - Nearest NeighborOriginal Rotated

Zoom In

Page 13: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image
Page 14: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Bi-linear• Bi-linear interpolates four closest pixels. • The weight for each pixel is proportional to its

distance from the sampling point (x,y)

Page 15: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Bi-linear Interpolation

Page 16: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Bi-linear Interpolation

Page 17: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Bi-linear Interpolation

Page 18: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Bi-linear Interpolation

Page 19: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Example Bi-linearOriginal Rotated

Zoom In

Page 20: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Bi-cubic

(u,v)

• Bicubic interpolates 16 closest neighbors (4x4 neighborhood)• The result is much more smooth

Page 21: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Bi-cubic Interpolation

Page 22: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Bi-cubic Interpolation

Page 23: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Bi-cubic Interpolation

Page 24: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Example Bi-cubicOriginal Rotated

Zoom In

Page 25: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Nearest Neighbor

Page 26: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Bi-Linear Interpolation

Page 27: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Bi-Cubic Interpolation

Page 28: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Comparison Nearest Neighbor Bi-linear Bi-cubic

Page 29: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image
Page 30: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Nearest neighbor sampling

Page 31: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Filtered Texture:

Page 32: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Texture Aliasing

• A single screen space pixel might correspond to many texels (texture elements):

Page 33: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Texture Mapping

Page 34: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Texture Pre-Filtering

• Problem: filtering the texture during rendering is too slow for interactive performance.

• Solution: pre-filter the texture in advance

– Summed area tables - gives the average value of each axis-aligned rectangle in texture space

– Mip-maps (tri-linear interpolation) - supported by most of today’s texture mapping hardware

Page 35: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

MIP-Maps

• Precompute a set of prefiltered textures (essentially an image pyramid).

• Based on the area of the pre-image of the pixel:– Select two “best” resolution levels– Use bilinear interpolation inside each level– Linearly interpolate the results

• Referred to as trilinear interpolation

Page 36: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

MIP Maps

Page 37: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

MIP Mapping• Lance Williams, 1983• Create a resolution pyramid of textures

– Repeatedly subsample texture at half resolution– Until single pixel– Need extra storage space

• Accessing– Use texture resolution closest to screen

resolution– Or interpolate between two closest resolutions

Page 38: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Texture Aliasing

• Image mapped onto polygon• Occur when screen resolution differs from texture

resolution• Magnification aliasing

– Screen resolution finer than texture resolution– Multiple pixels per texel

• Minification aliasing– Screen resolution coarser than texture resolution– Multiple texels per pixel

Page 39: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Minification Filtering

• Multiple texels per pixel• Potential for aliasing since texture signal

bandwidth greater than image• Box filtering requires averaging of texels• Precomputation

– MIP Mapping– Summed Area Tables

Page 40: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Summed Area Table• Frank Crow, 1984• Replaces texture map with summed-area texture

map– S(x,y) = sum of texels <= x,y– Need double range (e.g. 16 bit)

• Creation– Incremental sweep using previous computations– S(x,y) = T(x,y) + S(x-1,y) + S(x,y-1) - S(x-1,y-1)

• Accessing– Σ T([x1,x2],[y1,y2]) = S(x2,y2) – S(x1,y2) – S(x2,y1) + S(x1,y1)– Ave T([x1,x2],[y1,y2])/((x2 – x1)(y2 – y1))

x2,y2

x1,y1

x,yx-1,y-1

Page 41: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Summed Area Tables

• A 2D table the size of the texture. At each entry (i,j), store the sum of all texels in the rectangle defined by (0,0) and (i,j).

• Given any axis aligned rectangle, the sum of all texels is easily obtained from the summed area table:

C

B

A

D

DCBAarea +−−=

Page 42: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Quality considerations• Pixel area maps to “weird” (warped)

shape in texture space

pixel

u

v

xs

ys

Page 43: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Mip-maps• Find level of the mip-map where the area of each

mip-map pixel is closest to the area of the mapped pixel.

pixel

u

v

xs

ys

2x2 pixels level selected

Page 44: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Summed Area Table (SAT)

• Determining the rectangle:– Find bounding box and calculate its aspect ratio

pixel

u

v

xs

ys

Page 45: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Summed Area Table (SAT)

• Determine the rectangle with the same aspect ratio as the bounding box and the same area as the pixel mapping.

pixel

u

v

xs

ys

Page 46: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Elliptical Weighted Average (EWA) Filter

• Treat each pixel as circular, rather than square.• Mapping of a circle is elliptical in texel space.

pixel

u

v

xs

ys

Page 47: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Texture Domain

Page 48: מצגת של PowerPoint - TAUdcor/Graphics/cg-slides/rotation...• Precompute a set of prefiltered textures (essentially an image pyramid). • Based on the area of the pre-image

Elliptical Weighted Average