PROBLEMS
15.1. Prove the simple, but extremely useful, result that the perpendicular distance from a point (u, v) to a line (a, b, c) is given by abs(au + bv + c) if a2+ b2= 1.
Solution Work with the squared distance; choose a point (x, y) on the line, and we now wish to minimize (u− x)2+ (v− y)2subject to ax + by + c = 0. This gives
15.2. Derive the eigenvalue problem
µ x2− x x xy − x y
from the generative model for total least squares. This is a simple exercise — maximum likelihood and a little manipulation will do it — but worth doing right and remembering; the technique is extremely useful.
Solution We wish to minimiseP
i(axi+ byi+ c)2subject to a2+ b2= 1. This
where λ is the Lagrange multiplier. Now substitute back the third row (which is xa + yb + c = 0) to get the result.
15.3. How do we get a curve of edge points from an edge detector that returns orientation?
Give a recursive algorithm.
15.4. A slightly more stable variation of incremental fitting cuts the first few pixels and the last few pixels from the line point list when fitting the line because these pixels may have come from a corner
(a) Why would this lead to an improvement?
(b) How should one decide how many pixels to omit?
Solution
(a) The first and last few are respectively the end of one corner and the beginning of the next, and tend to bias the fit.
(b) Experiment, though if you knew a lot about the edge detector and the lens you might be able to derive an estimate.
71
72 Chapter 15 Segmentation by Fitting a Model
15.5. A conic section is given by ax2+ bxy + cy2+ dx + ey + f = 0.
(a) Given a data point (dx, dy), show that the nearest point on the conic (u, v) satisfies two equations:
au2+ buv + cv2+ du + ev + f = 0 and
2(a− c)uv − (2ady+ e)u + (2cdx+ d)v + (edx− ddy) = 0.
(b) These are two quadratic equations. Write u for the vector (u, v, 1). Now show that we can write these equations as uTM1u= 0 and uTM2u= 0, for M1 andM2symmetric matrices.
(c) Show that there is a transformationT , such that TTM1T = Id and TTM2T is diagonal.
(d) Now show how to use this transformation to obtain a set of solutions to the equations; in particular, show that there can be up to four real solutions.
(e) Show that there are four, two, or zero real solutions to these equations.
(f ) Sketch an ellipse and indicate the points for which there are four or two solu-tions.
Solution All this is straightforward algebra, except for (c) which gives a lot of people trouble. M1 is symmetric, so can be reduced to a diagonal form by the eigenvector matrix and to the identity using the square roots of the eigenvalues.
Now any rotation matrix fixes the identity; so I can use the eigenvector matrix of M2to diagonalize M2while fixing M1at the identity.
15.6. Show that the curve
(1− t2 1 + t2, 2t
1 + t2)
is a circular arc (the length of the arc depending on the interval for which the parameter is defined).
(a) Write out the equation in t for the closest point on this arc to some data point (dx, dy). What is the degree of this equation? How many solutions in t could there be?
(b) Now substitute s3= t in the parametric equation, and write out the equation for the closest point on this arc to the same data point. What is the degree of the equation? Why is it so high? What conclusions can you draw?
Solution Do this by showing that µ1− t2
1 + t2
¶2
+³ 2t 1 + t2
´2
= 1.
(a) The normal is
µ1− t2 1 + t2, 2t
1 + t2
¶ , so our equation is
(x−1− t2 1 + t2) 2t
1 + t2 + (y− 2t
1 + t2)(−1− t2 1 + t2) = 0,
and if we clear denominators by multiplying both sides by (1+t2)2, the highest degree term in t will have degree 4, so the answer is in principle 4. But if you expand the sum out, you’ll find that the degree 4 and degree 3 terms cancel, and you’ll have a polynomial of degree 2.
73
(b) It will have degree 6 in s; this is because the parametrisation allows each point on the curve to have three different parameter values (the s value for each t is t(1/3), and every number has three cube roots; it is very difficult in practice to limit this sort of calculation to real values only).
15.7. Show that the viewing cone for a cone is a family of planes, all of which pass through the focal point and the vertex of the cone. Now show the outline of a cone consists of a set of lines passing through a vertex. You should be able to do this by a simple argument without any need for calculations.
Solution The viewing cone for a surface consists of all rays through the focal point and tangent to the surface. Construct a line through the focal point and the vertex of the cone. Now construct any plane through the focal point that does not pass through the vertex of the cone. This second plane slices the cone in some curve. Construct the set of tangents to this curve that pass through the focal point (which is on the plane by construction). Any plane that contains the first line and one of these tangents is tangent to the cone, and the set of such planes exhausts the planes tangent to the cone and passing through the focal point. The outline is obtained by slicing this set of planes with another plane not lying on their shared line, and so must be a set of lines passing through some common point.
Programming Assignments
15.8. Implement an incremental line fitter. Determine how significant a difference results if you leave out the first few pixels and the last few pixels from the line point list (put some care into building this, as it’s a useful piece of software to have lying around in our experience).
15.9. Implement a hough transform line finder.
15.10. Count lines with an HT line finder - how well does it work?