G22.2274 Fall Advanced Computer Graphics

65
G22.2274001, Fall 2010 Advanced Computer Graphics Project details and tools 9/20/2010 1 Olga Sorkine, Courant Institute

Transcript of G22.2274 Fall Advanced Computer Graphics

Page 1: G22.2274 Fall Advanced Computer Graphics

G22.2274‐001, Fall 2010

Advanced Computer Graphics

Project details and tools

9/20/2010 1Olga Sorkine, Courant Institute

Page 2: G22.2274 Fall Advanced Computer Graphics

Projects

Details of each project are on the website under “Projects”

Please review all the projects and come see me if you would like to discuss details.

9/20/2010 Olga Sorkine, Courant Institute 2

Page 3: G22.2274 Fall Advanced Computer Graphics

Project Topics

Computer Animation

Interactive Shape Modeling

Computational PhotographyImage Processing

9/20/2010 3Olga Sorkine, Courant Institute

Page 4: G22.2274 Fall Advanced Computer Graphics

Code TipsSee links on the ‘Resources’ webpage!

For projects involving 2D only:You can use MATLAB and/or OpenCV

Not much UI involved

For projects in 3DI recommend OpenGL rendering with GLUT

For GUI you can use AntTweakBar or GLUI

If familiar: QT or other GUI APIs (more heavy‐weight)

Mesh libraries: see course website. Again, preference for light‐weight (trimesh).

9/20/2010 Olga Sorkine, Courant Institute 4

Page 5: G22.2274 Fall Advanced Computer Graphics

Optimization

Almost all projects have a global optimization component:

Define some energy functional E(x)x is the shape, or the image…

Compute the optimal x such that E(x) is minimized

There are some constraints to the minimization

9/20/2010 5Olga Sorkine, Courant Institute

Page 6: G22.2274 Fall Advanced Computer Graphics

Computer AnimationCharacter animation

Create a system for rigging and posing of digital characters (shapes)

Step 1: compute a skeleton

9/20/2010 6Olga Sorkine, Courant Institute

Page 7: G22.2274 Fall Advanced Computer Graphics

Computer AnimationCharacter animation

Create a system for rigging and posing of digital characters (shapes)

Step 1: compute a skeletonSuggestion: implement the paper “Skeleton Extraction by Mesh Contraction”, SIGGRAPH 2008

also implement GUI to manually create a skeleton

9/20/2010 7Olga Sorkine, Courant Institute

Page 8: G22.2274 Fall Advanced Computer Graphics

Computer AnimationCharacter animation

Function E(x) measures how smooth the shape x is

Constraints: extremities (finger tips, ears, etc.)

∑ ∑= ∈

−=n

i iNjjiji w

1

2

)()(E xxx

9/20/2010 8Olga Sorkine, Courant Institute

Page 9: G22.2274 Fall Advanced Computer Graphics

Geometric ModelingInteractive shape editing system

Implement one of the recent papers:“PriMo”, SGP 2006

The objective functional E(x) says the details of the shape should be preserved as much as possible

The constraints for the minimization are the user‐defined fixed positions

9/20/2010 9Olga Sorkine, Courant Institute

Page 10: G22.2274 Fall Advanced Computer Graphics

Interactive Shape ModelingSketch‐based modeling

Inflation of 2D sketches into a 3D shape

Objective E(x) measures how smooth the surface x is

The constraint is the silhouette curve

9/20/2010 Olga Sorkine, Courant Institute 10

User draws the silhouette

System meshes the interior

System inflatesthe shape

Page 11: G22.2274 Fall Advanced Computer Graphics

Implement a system for 3D painting on surfaces

Color from a curve is diffused by means of the Poisson equation

E(x) says the color field xshould be smooth

Constraints: colors of the curves

9/20/2010 Olga Sorkine, Courant Institute 11

Interactive Shape ModelingSketch‐based painting: diffusion curves on surfaces

Page 12: G22.2274 Fall Advanced Computer Graphics

Computational PhotographyShaky cam stabilization

Implement “Content‐Preserving Warps for 3D Video Stabilization”, SIGGRAPH 2009”

9/20/2010 12Olga Sorkine, Courant Institute

Page 13: G22.2274 Fall Advanced Computer Graphics

Computational PhotographyShaky cam stabilization

Implement “Content‐Preserving Warps for 3D Video Stabilization”, SIGGRAPH 2009”

E(x) measures:How well the quads are preserved(want all angles to be 90)

Constraints: point‐to‐point(match new projected position to the old position)

9/20/2010 13Olga Sorkine, Courant Institute

Page 14: G22.2274 Fall Advanced Computer Graphics

Image ProcessingImage retargeting (resizing)

The problem: resize an image to fit a display device with a different aspect ratio

9/20/2010 14Olga Sorkine, Courant Institute

Page 15: G22.2274 Fall Advanced Computer Graphics

Image ProcessingImage retargeting (resizing)

The problem: resize an image to fit a display device with a different aspect ratio

9/20/2010 15Olga Sorkine, Courant Institute

Page 16: G22.2274 Fall Advanced Computer Graphics

Image ProcessingImage retargeting (resizing)

Approach:Compute an importance map of the image

Warp the image such that regions with high importance are preserved at the expense of unimportant regions

importance map

9/20/2010 16Olga Sorkine, Courant Institute

Page 17: G22.2274 Fall Advanced Computer Graphics

Grid mesh, preserve the shape of the important quads

Optimize the location of mesh vertices, interpolate image

quads with high importance:uniform scaling

quads with low importance:allowed non‐uniform scaling

Image ProcessingImage retargeting (resizing)

9/20/2010 17Olga Sorkine, Courant Institute

Page 18: G22.2274 Fall Advanced Computer Graphics

Grid mesh, preserve the shape of the important quads

Optimize the location of mesh vertices, interpolate image

Image ProcessingImage retargeting (resizing)

9/20/2010 18Olga Sorkine, Courant Institute

Page 19: G22.2274 Fall Advanced Computer Graphics

Grid mesh, preserve the shape of the important quads

Optimize the location of mesh vertices, interpolate image

Image ProcessingImage retargeting (resizing)

9/20/2010 19Olga Sorkine, Courant Institute

Page 20: G22.2274 Fall Advanced Computer Graphics

E(x) measures:How well the quad shape is preserved

How smooth the grid lines are

Constraints:The boundary of the image(has to fit new dimensions)

Cropping constraints: all important content shouldremain in the resulting image

Image ProcessingImage retargeting (resizing)

9/20/2010 20Olga Sorkine, Courant Institute

Page 21: G22.2274 Fall Advanced Computer Graphics

Optimization

In the projects:mostly linear optimization, i.e.linear least‐squares problems

9/20/2010 21Olga Sorkine, Courant Institute

Page 22: G22.2274 Fall Advanced Computer Graphics

Solving linear systems in LS sense

Wish list of equations:

∀i =1, …, n: f (xi) = fi

Example: measuring surface smoothness

∑ ∑= ∈

−=n

i iNjjiji w

1

2

)()(E xxx

9/20/2010 22Olga Sorkine, Courant Institute

Page 23: G22.2274 Fall Advanced Computer Graphics

Solving linear systems in LS sense

Wish list of equations:

∀i =1, …, n: f (xi) = fi

Example: measuring surface smoothness

∑ ∑= ∈

−=n

i iNjjiji w

1

2

)()(E xxx

0:,,1)(

=−=∀ ∑∈ iNj

jiji wni xxK Wish equation

9/20/2010 23Olga Sorkine, Courant Institute

Page 24: G22.2274 Fall Advanced Computer Graphics

Solving linear systems in LS sense

We have an over‐determined linear system k × n:

a11 x1 + a12 x2 + … + a1n xn = b1

a21 x1 + a22 x2 + … + a2n xn = b2

…ak1 x1 + ak2 x2 + … + akn xn = bk

9/20/2010 24Olga Sorkine, Courant Institute

Page 25: G22.2274 Fall Advanced Computer Graphics

Solving linear systems in LS sense

In matrix form:

⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟

⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜

=

⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟

⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜

kknkk

n

n

aaa

aaaaaa

b

bb

2

1

21

22221

11211

M

K

MMM

K

K

K

⎟⎟⎟⎟⎟

⎜⎜⎜⎜⎜

nx

xx

2

1

M

9/20/2010 25Olga Sorkine, Courant Institute

Page 26: G22.2274 Fall Advanced Computer Graphics

Solving linear systems in LS sense

In matrix form:

Ax = bwhere A = (aij) is a rectangular k×n matrix, k > n

x = (x1, x2, …, xn)T b = (b1, b2, …, bk)T

9/20/2010 26Olga Sorkine, Courant Institute

Page 27: G22.2274 Fall Advanced Computer Graphics

Solving linear systems in LS sense

More constrains than variables – no exact solutions generally exist

We want to find something that is an “approximate solution”:

xopt = argmin ||Ax – b||2

min E(x)

x

x

9/20/2010 27Olga Sorkine, Courant Institute

Page 28: G22.2274 Fall Advanced Computer Graphics

Finding the LS solution

x ∈ Rn

Ax ∈ Rk

As we vary x,  Ax varies over the linear subspace of Rk spanned by the columns of A:

Ax = A2A1 An

x1x2..

xn

= x1 A1 A2 An+ x2 +… + xn

9/20/2010 28Olga Sorkine, Courant Institute

Page 29: G22.2274 Fall Advanced Computer Graphics

Finding the LS solution

We want to find the closest Ax to b: min ||Ax – b||2

Subspace spannedby columns of A

b

Rk

Axclosest to b

x

9/20/2010 29Olga Sorkine, Courant Institute

Page 30: G22.2274 Fall Advanced Computer Graphics

Finding the LS solution

The vector Ax closest to b satisfies:(Ax – b) ⊥ {subspace of A’s columns}

∀ column Ai: ⟨Ai, Ax – b⟩ = 0

∀ i,   AiT(Ax – b) = 0

AT(Ax – b) = 0(ATA)x = ATb

These arecalled the 

normal equations

9/20/2010 30Olga Sorkine, Courant Institute

Page 31: G22.2274 Fall Advanced Computer Graphics

Finding the LS solution

We got a square symmetric system (ATA)x = ATb

(n×n)

If A has full rank (the columns of A are linearly independent) then (ATA) is invertible.

( ) bx

bx

T1T

2

x

AAA

Amin

−=

9/20/2010 31Olga Sorkine, Courant Institute

Page 32: G22.2274 Fall Advanced Computer Graphics

Weighted least squares

If each constraint has a weight in the energy:

The weights wi > 0 and don’t depend on xThen:

min (Ax – b)T W(Ax – b) where W = (wi)ii

(AT W A) x = AT W b

∑=

−n

1

2))(f(mini

iiiiw bxx

9/20/2010 32Olga Sorkine, Courant Institute

Page 33: G22.2274 Fall Advanced Computer Graphics

Linear Systems

Matrix is often fixed, rhs changes

M x = r

ATA bAT

9/20/2010 33Olga Sorkine, Courant Institute

Page 34: G22.2274 Fall Advanced Computer Graphics

Matrix FactorizationLU decomposition

M = LU

Mx = rLUx = r

9/20/2010 34Olga Sorkine, Courant Institute

Page 35: G22.2274 Fall Advanced Computer Graphics

Matrix FactorizationLU decomposition

M = LU

Mx = rL(Ux) = r

9/20/2010 35Olga Sorkine, Courant Institute

Page 36: G22.2274 Fall Advanced Computer Graphics

Matrix FactorizationLU decomposition

M = LU

Mx = rL(Ux) = r

Ly = rUx = y

This is backsubstitution.If L, U are sparse it is very fast. The hard work is computing  L and U

9/20/2010 36Olga Sorkine, Courant Institute

Page 37: G22.2274 Fall Advanced Computer Graphics

Matrix FactorizationLU decomposition

M = LU

Mx = rL(Ux) = r

y = L–1rx = U–1y

This is backsubstitution.If L, U are sparse it is very fast. The hard work is computing  L and U

9/20/2010 37Olga Sorkine, Courant Institute

Page 38: G22.2274 Fall Advanced Computer Graphics

Matrix FactorizationCholesky decomposition

M = LLT

Cholesky factor exists if M is positive definite. It is even better than LU because we save memory.

9/20/2010 38Olga Sorkine, Courant Institute

Page 39: G22.2274 Fall Advanced Computer Graphics

Cholesky Decomposition

M is symmetric positive definite (SPD):

∀ x≠0, ⟨Mx, x⟩ > 0 ⇔ all M’s eigenvalues > 0

M = LLT

M = LLT

9/20/2010 39Olga Sorkine, Courant Institute

Page 40: G22.2274 Fall Advanced Computer Graphics

Dense Cholesky Factorization

M = LLT

500×500 matrix3500 nonzeros

L36k nonzeros

Cholesky Factorization

9/20/2010 40Olga Sorkine, Courant Institute

Page 41: G22.2274 Fall Advanced Computer Graphics

Sparse Cholesky Factorization

M = LLT

500×500 matrix3500 nonzeros

L36k nonzeros

Cholesky Factorization

Reordering

PMPTreverse Cuthill‐McKee algorithm

9/20/2010 41Olga Sorkine, Courant Institute

Page 42: G22.2274 Fall Advanced Computer Graphics

M = LLT

500×500 matrix3500 nonzeros

L36k nonzeros

Cholesky Factorization

Reordering

PMPTreverse Cuthill‐McKee algorithm

L14k nonzeros

Sparse Cholesky Factorization

9/20/2010 42Olga Sorkine, Courant Institute

Page 43: G22.2274 Fall Advanced Computer Graphics

Sparse Cholesky Factorization

M = LLT

500×500 matrix3500 nonzeros

L36k nonzeros

Cholesky Factorization

Reordering

PMPTnested dissection(parallelizable)

9/20/2010 43Olga Sorkine, Courant Institute

Page 44: G22.2274 Fall Advanced Computer Graphics

Sparse Cholesky Factorization

M = LLT

500×500 matrix3500 nonzeros

L36k nonzeros

Cholesky Factorization

Reordering

PMPTnested dissection(parallelizable)

L7k nonzeros

9/20/2010 44Olga Sorkine, Courant Institute

Page 45: G22.2274 Fall Advanced Computer Graphics

Direct SolversDiscussion

Highly accurateManipulate matrix structure

No iterations, everything is closed‐form

Easy to useOff‐the‐shelf library, no parameters

If M stays fixed, changing rhs (r) is cheapJust need to back‐substitute (factor precomputed)

9/20/2010 45Olga Sorkine, Courant Institute

Page 46: G22.2274 Fall Advanced Computer Graphics

Direct SolversDiscussion

High memory costNeed to store the factor, which is typically denser than the matrix M

If the matrix M changes, need to re‐compute the factor (expensive)

9/20/2010 46Olga Sorkine, Courant Institute

Page 47: G22.2274 Fall Advanced Computer Graphics

TAUCS tutorial

TAUCS: a library of sparse linear solversHas both iterative and direct solvers

Direct (Cholesky and LU) use reordering and are very fast

I provide a wrapper for TAUCS on the course homepage 

9/20/2010 47Olga Sorkine, Courant Institute

Page 48: G22.2274 Fall Advanced Computer Graphics

TAUCS tutorial

Basic operations:Define a sparse matrix structure

Fill the matrix with its nonzero values (i, j, v)

Factor ATA

Provide an rhs and solve

9/20/2010 48Olga Sorkine, Courant Institute

Page 49: G22.2274 Fall Advanced Computer Graphics

TAUCS tutorial

Basic operations:Define a sparse matrix structure

InitTaucsInterface();

int idA;idA = CreateMatrix(4, 3);

#rows     #cols

9/20/2010 49Olga Sorkine, Courant Institute

Page 50: G22.2274 Fall Advanced Computer Graphics

TAUCS tutorial

Basic operations:Fill the matrix A with its nonzero values (i, j, v)

SetMatrixEntry(idA, i, j, v);

9/20/2010 50Olga Sorkine, Courant Institute

Page 51: G22.2274 Fall Advanced Computer Graphics

TAUCS tutorial

SetMatrixEntry(idA, i, j, v);

matrix ID, obtained in CreateMatrix

Basic operations:Fill the matrix A with its nonzero values (i, j, v)

9/20/2010 51Olga Sorkine, Courant Institute

Page 52: G22.2274 Fall Advanced Computer Graphics

TAUCS tutorial

Basic operations:Fill the matrix A with its nonzero values (i, j, v)

SetMatrixEntry(idA, i, j, v);

row index i, column index j,zero‐based

9/20/2010 52Olga Sorkine, Courant Institute

Page 53: G22.2274 Fall Advanced Computer Graphics

TAUCS tutorial

Basic operations:Fill the matrix A with its nonzero values (i, j, v)

SetMatrixEntry(idA, i, j, v);

value of matrix entry ijfor instance, –wij

9/20/2010 53Olga Sorkine, Courant Institute

Page 54: G22.2274 Fall Advanced Computer Graphics

TAUCS tutorial

Basic operations:Factor the matrix ATA

FactorATA(idA);

9/20/2010 54Olga Sorkine, Courant Institute

Page 55: G22.2274 Fall Advanced Computer Graphics

TAUCS tutorial

Basic operations:Provide an rhs and solve

taucsType b[4] = {3, 4, 5, 6};taucsType x[3];

SolveATA(idA, b, x, 1);

9/20/2010 55Olga Sorkine, Courant Institute

Page 56: G22.2274 Fall Advanced Computer Graphics

TAUCS tutorial

Basic operations:Provide an rhs and solve

taucsType b[4] = {3, 4, 5, 6};taucsType x[3];

SolveATA(idA, b, x, 1);

typedef for double

9/20/2010 56Olga Sorkine, Courant Institute

Page 57: G22.2274 Fall Advanced Computer Graphics

TAUCS tutorial

Basic operations:Provide an rhs and solve

taucsType b[4] = {3, 4, 5, 6};taucsType x[3];

SolveATA(idA, b, x, 1);

ID of the A matrix

9/20/2010 57Olga Sorkine, Courant Institute

Page 58: G22.2274 Fall Advanced Computer Graphics

TAUCS tutorial

Basic operations:Provide an rhs and solve

taucsType b[4] = {3, 4, 5, 6};taucsType x[3];

SolveATA(idA, b, x, 1);

rhs for the LS system Ax = b

9/20/2010 58Olga Sorkine, Courant Institute

Page 59: G22.2274 Fall Advanced Computer Graphics

TAUCS tutorial

Basic operations:Provide an rhs and solve

taucsType b[4] = {3, 4, 5, 6};taucsType x[3];

SolveATA(idA, b, x, 1);

array for the solution

9/20/2010 59Olga Sorkine, Courant Institute

Page 60: G22.2274 Fall Advanced Computer Graphics

TAUCS tutorial

Basic operations:Provide an rhs and solve

taucsType b[4] = {3, 4, 5, 6};taucsType x[3];

SolveATA(idA, b, x, 1);

number of rhs’s

A is 4x3

9/20/2010 60Olga Sorkine, Courant Institute

Page 61: G22.2274 Fall Advanced Computer Graphics

TAUCS tutorial

Basic operations:Provide an rhs and solve

taucsType b2[8] = {3, 4, 5, 6, 7, 8, 9, 10};taucsType xy[6];

SolveATA(idA, b2, xy, 2);

number of rhs’s

A is 4x3

9/20/2010 61Olga Sorkine, Courant Institute

Page 62: G22.2274 Fall Advanced Computer Graphics

TAUCS tutorial

If the matrix A is square a priori, no need to solve the LS systemThen just use FactorA()and SolveA()

9/20/2010 62Olga Sorkine, Courant Institute

Page 63: G22.2274 Fall Advanced Computer Graphics

Further Reading

Efficient Linear System Solvers for Mesh Processing Mario Botsch, David Bommes, Leif KobbeltInvited paper at IMA Mathematics of Surfaces XI, Lecture Notes in Computer Science, Vol 3604, 2005, pp. 62‐83. 

9/20/2010 63Olga Sorkine, Courant Institute

Page 64: G22.2274 Fall Advanced Computer Graphics

Next week

By September 27 you must:Read up on all the projects and decide on your priorities

Discuss with me if you’d like to do a customized project (your own ideas)

E‐mail me your project preference (ranked list)

No class meeting (do homework! ☺ )

9/20/2010 64Olga Sorkine, Courant Institute

Page 65: G22.2274 Fall Advanced Computer Graphics

Next week and after

On September 28 I will assign a project to everyoneNext class: October 4; everyone presents their initial project planUp to 20 minutes presentation (can be shorter)

Explain the project in your words, with technical detailsOutline your work planBring up things that are unclear/challenges you foresee

9/20/2010 65Olga Sorkine, Courant Institute