4

I have this problem that I cannot figure out how to solve. It is from Szeliski's computer vision book (http://szeliski.org/Book/drafts/SzeliskiBook_20100903_draft.pdf) p.94 (electronic version) and is as follows:

If you are given more than two lines and want to find a point $\widetilde{x}$ that minimizes the sum of squared distances to each line,

$$ D = \sum_{i}(\widetilde{x} \cdot \widetilde{l}_i)^2 $$

how can you compute this quantity? (Hint: Write the dot product as $\widetilde{x}^T\widetilde{l_i}$ and turn the squared quantity into a quadratic form, $\widetilde{x}^TA\widetilde{x}$.)

The tilde sign is used to denote points in homogenous coordinates.

I have turned the expression into this expression, which is the authors hint:

$$ \sum_{i}(\widetilde{x}^T\widetilde{l_i})(\widetilde{x}^T\widetilde{l_i}) = \sum_{i}(\widetilde{x}^T\widetilde{l_i})(\widetilde{l_i}^T\widetilde{x}) = \sum_{i}\widetilde{x}^TA\widetilde{x} $$

A is then: $\widetilde{l_i}\widetilde{l_i}^T$

How do I proceed from here? How does rewriting the sum to a sum of quadratic from help me? I can take the derivative and find a x that minimizes the squared sum?

The lines are in 2D expressed using homogenous coordinates resulting in 3D vectors. Does anyone know how to solve this using the quadratic form expression (using matrix stuff)

lirre
  • 41
  • You want to define $A=\sum l_il_i^T$. Then $A\ge 0$ (it is a sum of projections) and you can minimize by making use of eigenvectors with minimal eigenvalue. Except that it doesn't quite work meaningfully with your formulae: obviously, $x=0$ minimizes. That's because all your lines go through the origin. You want to consider (more generally) lines of the type $x\cdot l = c$, with general $c\in\mathbb R$. –  Jul 03 '14 at 18:50
  • I was a bit unclear when I specified the question. The lines are 2D lines expressed using homogenous coordinates. So the vector representing the 2D line is of 3 dimensions. But I think there might be a typo in the specification of the question. I think that x~ (x with tilde above) should be a 2D vector and normalized by dividing to it's 3rd component, giving a thrird component of 1. Then this is a general line as you wrote, but in 2 dimesions only. – lirre Jul 04 '14 at 07:27
  • Hi lirre, have you solved with the question submitted by I disagree? – elect Jun 22 '15 at 10:13

2 Answers2

1

Since the sum $\sum_i$ in $D(x)$ is over $i$ (not $x$), you can factor out $x$ to get the quadratic form:

$$ D(x) = x^T (\sum_i l_i l_i^T) x = x^T A x. $$

The rest is about minimizing quadratic forms. To prevent duplication, see [1] for how to minimize that.

[1] Minimization of a convex quadratic form

hyiltiz
  • 268
1

I'll try to keep it concrete, without matrix notation. For each line find a vector $(a_i,b_i)$ of unit norm that is perpendicular to it. (Take two points on the line, subtract to get a vector, rotate by 90 degrees, and divide by the length.) The equation of the line is of the form $a_ix+b_iy+c_i=0$. Here $a_ix+b_iy+c_i$ is the distance to the line, up to the sign. So, the sum of squared distances is $$ \sum_i (a_ix+b_iy+c_i)^2 $$ To minimize, take partial derivatives and set them to zero: $$ \sum_i 2a_i(a_ix+b_iy+c_i) =0,\qquad \sum_i 2b_i(a_ix+b_iy+c_i) =0 $$ This is a pretty simple system (2 equations, 2 unknowns), which can be written as $$ x\sum a_i^2 + y \sum a_i b_i + \sum a_i c_i=0, \qquad x\sum a_ib_i + y \sum b_i^2 + \sum b_i c_i=0$$ The solution is unique, unless your lines are all parallel.

  • At first it was very confusing what you meant, but I read this link: http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html Which explains what you are saying.So the idea is to find a normal vector to a line and then take a point on the line and project it to the normal vector which will be the squared distance. Which is the expression you wrote in the top. There a typo in you eval. of partial deriv.? I think the 2 outside the sum should be removed, right? I mean we have to use the chainrule with respect to x and y. partial derivative of x is: $\sum_{i}2a_i(a_ix+b_iy+c_i)$, right? – lirre Jul 04 '14 at 08:43
  • *which will be the squared distance => which will be the distance – lirre Jul 04 '14 at 09:00
  • @lirre Typo corrected. –  Jul 04 '14 at 13:43
  • Let's suppose I have $a_0 (1, 3)$ and $b_0 (2, 2)$. I get the $\vec v = a_0 - b_0 = (-1, 1)$ and rotate it $(-1, -1)$. Now I divide it by its length $\sqrt[2]{2}$ and get $\vec v = (-\frac {1}{\sqrt[2]{2}}, -\frac {1}{\sqrt[2]{2}})$ – elect Jun 16 '15 at 12:33
  • Now how would I get $a_ix+b_iy+c_i$ from that? – elect Jun 16 '15 at 12:38
  • Sorry but I don't get if your answer is for 2d or 3d lines.. – elect Jun 22 '15 at 14:53