1. Using Algebraic Geometry for
Solving Polynomial Problems
in Computer Vision
David Nistér and Henrik Stewénius
2. Very Rough Outline
• 14:00-15:30 “1st
Round", administered by David.
• - What is this Tutorial About?
• - Motivation, RANSAC, Example Problems
• - Gröbner Bases
• - Action Matrix
• -15:30-16:00 Coffee break
• 16:00-18:00-“2nd
Round“, administered by Henrik.
• - Background Material
• - Gröbner Bases
• - Exercises in Macaulay2
• - Q & A
3. What is this Tutorial About?
• If you are interested in solving polynomial
equations, this tutorial is for you
• This tutorial is a ‘real’ tutorial
• The main focus will be on Gröbner bases
and how the theory of Gröbner bases can be
used to solve polynomial equations
5. RISC
Research
Institute for
Symbolic
Computation
Linz, Austria
Wolfgang Gröbner (1899-1980) Bruno Buchberger
1966: Ph.D. in mathematics. University of Innsbruck,
Dept. of Mathematics, Austria.
Thesis: On Finding a Vector Space Basis of the Residue Class Ring
Modulo a Zero Dimensional Polynomial Ideal (German).
Thesis Advisor: Wolfgang Gröbner
6. Bezout’s Theorem
2x2=4
Mixed Volume, see for example [CLO 1998]
provides a generalization for non-general polynomials.
With two variables,
a solution according to
the Bezout bound
can typically be
realized with resultants.
With three or more
variables, things
are less simple.
8. Various States of Mind You May Have, I:
• Skip the theory, what is this all about? –Answers
from David
1st
Quadrant2st
Quadrant
3rd
Quadrant 4th
Quadrant
Difficult TheoryEasy Theory
Useful Theory
Useless Theory
Useful but HardUseful and Easy
Super!
Useless and Easy
Useless and impossible
to penetrate – Unfortunately
survives
Algebraic Geometry and
Gröbner Bases
9. Proofs of the Power of Gröbner Bases
• So far, approx. 600 publications and 10 textbooks have been devoted to
Gröbner Bases.
• Gröbner Bases are routinely available in current mathematical software
systems like Mathematica, Maple, Derive, Magma, Axiom, etc.
• Special software systems, like CoCoa, Macaulay, Singular, Plural, Risa-Asir
etc. are, to a large extent, devoted to the applications of Gröbner Bases.
• Gröbner Bases theory is an important section in all international conferences
on computer algebra and symbolic computation.
• Gröbner Bases allow, for the first time, algorithmic solutions to some of the
most fundamental problems in algebraic geometry but are applied also in such
diverse areas as functional analysis, statistics, optimization, coding theory,
cryptography, automated theorem proving in geometry, graph theory,
combinatorial identities, symbolic summation, special functions, etc.
10. • Stop the handwaving, what is the rigorous
theory?
Answers from David and Henrik + books
Various States of Mind You May Have, II:
11. Suggested Literature
• D. Cox, J. Little, D. O’Shea, Ideals, Varieties,
and Algorithms, Second Edition, 1996.
• D. Cox, J. Little, D. O’Shea, Using Algebraic
Geometry, Springer 1998.
• T. Becker and Weispfennig, Gröbner Bases, A
Computational Approach to commutative Algebra,
Springer 1993.
12. Suggested Literature
• B. Buchberger, F. Winkler (eds.) Gröbner
Bases and Applications
Cambridge University Press, 1998.
• Henrik’s Thesis: H. Stewénius, Gröbner
Basis Methods for Minimal Problems in
Computer Vision, PhD Thesis, 2005
• Planned scaffolding paper, keep a lookout
on the tutorial web page
13. • Skip the theory, how do I use it? – Answers
from Henrik, Exercises in Macaulay 2.
Various States of Mind You May Have, III:
21. For Which Problems Did We Use
Gröbner Bases?
The Generalized
3-Point Problem
YesNo Yes, you bet
The 3 View 4-Point
Problem
8(4)
10
2048
The 5-Point Relative
Pose Problem
0 (or thousands)
47
3 View
Triangulation
Unknown Focal
Relative Pose
15
64
Generalized Relative
Pose
Microphone-Speaker
Relative Orientation
8-38-150-344-??
201. 5-Point Matlab Executable
Recent Developments on Direct Relative Orientation,
Henrik Stewenius, Christopher Engels, David Nister,
To appear in ISPRS Journal of Photogrammetry and Remote Sensing
www.vis.uky.edu/~dnister
202. 6-point generalized relative orientation (64 solutions) (Stewenius,
Nistér, Oskarsson and Åström, Omnivis ICCV 2005)
6-point relative orientation with common but unknown focal length
(15 solutions) (Stewenius, Nistér, Schaffalitzky and Kahl,
to appear at CVPR 2005)
Further Examples of Solved Problems
221. For Which Problems Did We Use
Gröbner Bases?
The Generalized
3-Point Problem
YesNo Yes, you bet
The 3 View 4-Point
Problem
8(4)
10
2048
The 5-Point Relative
Pose Problem
0 (or thousands)
47
3 View
Triangulation
Unknown Focal
Relative Pose
15
64
Generalized Relative
Pose
Microphone-Speaker
Relative Orientation
8-38-150-344-??
222. Camera Geometry
• Often leads to polynomial formulations,
or can at least very often be formulated in
terms of polynomial equations
224. Main Point
• Gröbner Basis Gives Action Matrix
(because it provides the ability to compute unique ‘smallest’ possible
unique remainders)
• Action Matrix Gives Solutions
Polynomial
Equations
Gröbner
Basis
Action
Matrix
Solutions
Intensively Studied
225. Algebraic Ideal
• I(p1 , … , pn)= The set of polynomials
generated by the input polynomials
(through additions and multiplications by a polynomial)
p and q in I => p+q in I
p in I => pq in I
The ideal I consists of ‘Almost’ all the polynomials implied
by the input polynomials
(More precisely, the radical of the ideal consists of all)I
226. Basis (for Ideal)
• A basis for the ideal J is a set of polynomials
{p1 , … , pn} such that J=I(p1 , … , pn)
227. Algebraic Variety
• The solution set
(the vanishing set of the input polynomials)
V(I)={x:I(x)=0}
More precisely
p(x)=0 for all p in I
228. Quotient Ring J/I
• The set of equivalence classes of
polynomials when only the values on V are
considered (i.e. polynomials are equivalent iff p(V)=q(V))
V(I)
p in J/I
229. Action Matrix
• For multiplication by polynomial on finite
dimensional solution space
V(I)
231. An ‘Equivalence’
Finding the Roots
of a Polynomial
Finding the Eigenvalues
of a Matrix
Compute Companion
Matrix
Compute
Characteristic Polynomial
Finding the Roots
of a Multiple
Polynomial Equations
Finding the Eigenvalues
of a Matrix
Compute Action Matrix in Quotient Ring
(Polynomials modulo Input Equations)
Compute
Characteristic Polynomial
Requires
Gröbner
Basis for
Input Equations
232. Companion Matrix
x2
1x3
x4
x5
x6
x7
+ a6x6
+a5x5
+ a4x4
+ a3x3
+ a2x2
+ a1x+a0
-a6
1
1
1
1
1
-a0-a4 -a3 -a2 -a1-a5
x
1
Multiplication by x modulo the seventh degree polynomial
can be expressed as left-multiplication by the matrix
240. Action Matrix
Multiplication by a polynomial q is a linear
operator Aq
(αp+βr)q=α(pq)+β(rq)
The matrix Aq is called the action matrix for
multiplication by q
244. Action Matrix
I
The values q(xi) of q at the solutions xi are the
eigenvalues of the action matrix
q(x1)b1
q(x2)b2
q(x0)b0
q in J
245. Action Matrix
The values q(xi) of q at the solutions xi are the
eigenvalues of the action matrix
If we choose q=y1 , the eigenvalues are the
solutions for y1
246. Action Matrix
b’(x)Aq p=q(x)b’(x)p
for all p in J/I and x in V(I)
b’=[r1 … ro]
b’(x)Aq =b’(x)q(x)
b(x) is a left nullvector of Aq corresponding to eigenvalue q(x)
247. Monomial Order
• Needed to define leading term of a polynomial
• Grevlex (Graded reverse lexicographical) order
usually most efficient
y_1
y_2
248. Gröbner Basis
• A basis for ideal I that exposes the leading
terms of I (hence unique well defined remainders)
• Easily gives the action matrix for
multiplication with any polynomial in the
quotient ring
y_1
y_2
249. A Reduced Gröbner Basis is a Basis
in the normal sense
• A polynomial in the ideal I can be written
as a unique combination of the polynomials
in a reduced Gröbner basis for I
• The monic Gröbner basis for I is unique
251. Gaussian Elimination
Exposes all the leading terms, which are simply
all the variables in the case of general linear equations
xn x1
252. Remember Row Operations:
• Multiplying a row by a scalar
• Subtracting a row from another
• Swap rows
Add:
• Multiplying a row by any polynomial
253. More General Elimination
With non-linear equations, there are relations between
the monomials that matter when multiplying
x2
xyy2
xy
Multiply by x
Multiply by y
x2
xyy2
xy
x2
xyy2
xy
254. Multiplying by a Scalar
p(x)
3.8p(x)
Transitions through zero remain
268. Elimination
Schedule
Approach
Pose Problem over R
Compute Gröbner basis
End
Compute Action Matrix
Solve Eigenproblem
Backsubstitute
Begin (online)
Pose Problem. Port to Zp
Compute number of solutions
End
Build matrix based
Gröbner basis code
Port to R
Begin (offline)
269. Prime Field Formulation
• Reals => Cancellation unclear
• Rationals => Grows unwieldy
• Prime Field => Cancellation clear, size is
limited, only small risk of incorrect
cancellation if prime is large
Now, lets look at the animation. In order to bring the three points to the three rays, we are allowed to translate which makes for three degrees of freedom, and rotate, which makes for three degrees of freedom.
If we assume that we have the aligment in place, and forget about the constraint from the third ray for a minute, what are two degrees of freedom that are left?
Well, if we consider the axis through the first two points, and we rotate the point configuration around the axis through the first two points, we will clearly not disturb the first two constraints. This causes the third point to move in a circle around the axis.
So what about the second degree of freedom? The key is to consider the perpendicular axis between the first two rays. If we perform a slight 3D transformation of everything so that we are looking straight down the perpendicular axis, like this, and we look at this in an orthographic projection,
then we find that we can apply Euclid’s proposition III:21.
We wish to keep the first two rays through their corresponding points. Euclid III:21 tells us that we can do this with a revolving motion that moves the perpendicular axis around in a circle. This is the second degree of freedom. The interesting thing to study is now what happens to the third ray when we perform this revolving motion.
It turns out that every point on the third ray moves around on a plane curve called a Limacon, like this. Moreover, the whole ray traces out a quartic surface. Being traced out by a line, the surface is of course ruled.
The solutions to the problem therefore correspond to the points where the quartic surface meets the circle.
The shape of the surface varies with the configuration of the first two points and the three rays. It is built up by limacons in each plane,
and has a curve of self-intersection, which turns out to be parts of a twisted cubic.
An interesting question is what happens to the geometry in the classical case.
It turns out that in the classical case, the problem attains a certain symmetry.
The surface becomes symmetric across the plane that appears like a waist in this figure. The self-intersection curve becomes a circle that looks like a waist, and an infinite vertical line. Moreover, the circle is also upright and symmetric with respect to the plane of the waist. So everything has reflection symmetry across the plane of the waist. Because of this, the solutions come in pairs in the classical case. The reflected solutions correspond to reflecting the projection centre across the plane of the three points.
Because of the reflection symmetry, it is possible to find the solutions in closed form, since there is a quartic polynomial whose roots correspond to pairs of solutions.