Image Rectification

Total Page:16

File Type:pdf, Size:1020Kb

Image Rectification ECE 181b Homework 3 Image Rectification April 20, 2006 The goal of this project is to explore some fundamental concepts of projective geometry related to the problem of image rectification. We will rectify the image of one of the facades of the Bren School of Environmental Science & Management at UCSB (see Figure 1) and verify how points at infinity can be mapped to finite points via homographies. Caveat. To receive full credit your answers must be clearly justified. Make sure to include the relevant steps that were required to obtain the numerical answer. 1 Calculating the Homography A transformation from the projective space P2 to itself is called homography. A homography is represented by a 3 × 3 matrix with 8 degrees of freedom (scale, as usual, does not matter): 0 x h1 h4 h7 x 0 y = h2 h5 h8 y 0 w h3 h6 h9 w To estimate the coefficients of the homography H we will use the approach described in class (see the notes that can be found at http://www.ece.ucsb.edu/~manj/ece181b/ homography_zuliani.pdf). The test images can be downloaded from the course website. For sake of convenience we will adopt the coordinate system convention displayed in Figure 2 (for a more detailed image go to http://vision.ece.ucsb.edu/~zuliani/Code/lattice. png). Question 1 How many point correspondences are necessary to compute the homography that relates Image 1(a) to Image 1(b) under the constrain that the vector h obtained stacking the components of H one on top of the other has unit norm (i.e. khk = 1)? Why? Answer 1 We need at least 4 point correspondences. In fact each point correspondence provides two equations (for a total of 8 constraints) and we have 9 unknowns. The extra degree of freedom is fixed by imposing khk = 1. 1 (a) (b) Figure 1: Image (a) shows a perspective view of one of the (almost) planar facades of the Bren School. Our goal is to the calculate the warping that will transform image (a) as if the picture was taken with the camera image plane parallel to the facade plane (e.g. image (b)). Thorough all this homework we will refer to the quantities related to Image (b) using the superscript 0. Question 2 With the help of Matlab, answer the following questions: • Manually select N point correspondences and estimate the homography that maps the points in Image 1(a) to the points in Image 1(b) (you are expected to provide the numerical values of the homography that you estimated). You may want to use the Matlab function that was described in class (see the course webpage to download the code). • How is the number of points that are selected affecting the accuracy of the homography estimate? • Explain why it is crucial that the chosen points do not form a “singular configuration”. • Provide an example of a singular configuration. 305 Where does the estimated homography map the point x = ? • 379 Suggestion. We suggest to pick a reasonable large number of points, not just 4. To select these points you may want to give a look to the matlab function ginput or, if the image processing toolbox is available, to the fancier function cpselect. 2 Figure 2: The coordinate system convention that is to be adopted in this homework. Answer 2 The estimate of the homography (calculated using 42 points, under the constraint khk = 1) is given by: −0.0022 0.0014 −0.9466 H = 0.0002 −0.0019 −0.3224 0.0000 0.0000 −0.0060 The larger is N the more accurate is the estimate of the homography (provided that the set of point correspondences does not include any outliers). If the points were chosen in a singular configuration (e.g. along a line), then the matrix associated to the homogeneous linear system of the DLT algorithm becomes ill conditioned and small amounts of noise in the position of the points will produce large fluctuations in the coefficients of the homography. To calculate the position of the point x we just need to convert to cartesian coordinates the following homogenous expression: −0.0022 0.0014 −0.9466 305 Hx = 0.0002 −0.0019 −0.3224 379 0.0000 0.0000 −0.0060 1.0000 298.7273 We therefore obtain x0 = 280.0202 Question 3 With the help of Matlab, answer the following questions: • After reading the help, use the function WarpHomography (which can be downloaded from the course website) to compute the rectified version of Image 1(a). Include the images in your answer. • Comment on the differences that you notice between the two output images that are aligned to the same coordinate system. 3 (a) (b) Figure 3: The images rendered by the function WarpHomography. Answer 3 The images produced by the function WarpHomography are shown in Figure 3. The differences in the overlapping portions of the images are due to the fact that the hypoth- esis that the scene is planar does not hold everywhere (note the portion of the grass in the bottom right corner of Image 1(a) and the depth discontinuities in correspondences of the windows). 2 Homographies and Points at Infinity In the projective space parallel lines intersect at a point at infinity. An homography can map a point at infinity into a point that has finite cartesian coordinates. Using the images in Figure 1 we will show how this can happen. Question 4 Consider the two lines shown in Figure 4 (corresponding to Image 1(b)), whose 0 T projective representation is lR = −11 0 3300 (line containing the red segment) and 0 T lG = −11 0 3383 (line containing the green segment). With the help of Matlab, answer the following questions: • Compute the projective representation q0 of the intersection between the two lines. • Where is this point located? • What are the expressions lR and lG (both analytical and numerical) of the lines in the coordinate system of Figure 1(a)? • Compute their intersection and call it q. What is the cartesian representation of q? • When you try to position q in Image 1(a), does your result make sense? • How is q analytically related to q0? 4 0 0 Figure 4: The segments that identify the lines lR and lG. Answer 4 In the projective space P2, the intersection between two lines can be easily com- puted taking the cross product between the vectors that represent the lines: −11 0 3300 0 0 0 0 q = lR × lG = −11 0 3383 ∼ 1 i j k 0 Since the third component of the vector is equal to zero, we are dealing with a point at infinity (as expected for the intersection of two parallel lines). The expression for the lines in the coordinate frame of Image 1(a) can be obtained via the transpose of the homography computed T 0 T 0 in Question 2: lR = H lR and lG = H lG (remember the duality principle). In matlab: 0001 % apply mapping 0002 l R = transpose(H)*l R prime; 0003 % normalize 0004 l R = l R/l R(3); Thus we obtain: −0.0026 0 lR ∼ −0.0006 1.0000 and: −0.0019 0 lG ∼ −0.0007 1.0000 The intersection can be once again computed via the cross product: −0.0026 −0.0006 1.0000 183.2369 q = lR × lG = −0.0019 −0.0007 1.0000 ∼ 947.3679 i j k 1.0000 where the cartesian representation corresponds to the first two components of the homoge- neous vector. The results makes sense, since q is located on the top left of Image 1(a), where 5 0 the remapped lines lR and lG intersect. Finally q is related to q via the inverse of the ho- mography H, so that q = H−1q0. As mentioned in class, for numerical conditioning reasons, rather than using the Matlab function inv, it is better if we use the backslash operator: 0001 % use backslash operator rather than inv function 0002 q = H\q prime; 0003 % normalize 0004 q = q/q(3); 6.
Recommended publications
  • Projective Geometry: a Short Introduction
    Projective Geometry: A Short Introduction Lecture Notes Edmond Boyer Master MOSIG Introduction to Projective Geometry Contents 1 Introduction 2 1.1 Objective . .2 1.2 Historical Background . .3 1.3 Bibliography . .4 2 Projective Spaces 5 2.1 Definitions . .5 2.2 Properties . .8 2.3 The hyperplane at infinity . 12 3 The projective line 13 3.1 Introduction . 13 3.2 Projective transformation of P1 ................... 14 3.3 The cross-ratio . 14 4 The projective plane 17 4.1 Points and lines . 17 4.2 Line at infinity . 18 4.3 Homographies . 19 4.4 Conics . 20 4.5 Affine transformations . 22 4.6 Euclidean transformations . 22 4.7 Particular transformations . 24 4.8 Transformation hierarchy . 25 Grenoble Universities 1 Master MOSIG Introduction to Projective Geometry Chapter 1 Introduction 1.1 Objective The objective of this course is to give basic notions and intuitions on projective geometry. The interest of projective geometry arises in several visual comput- ing domains, in particular computer vision modelling and computer graphics. It provides a mathematical formalism to describe the geometry of cameras and the associated transformations, hence enabling the design of computational ap- proaches that manipulates 2D projections of 3D objects. In that respect, a fundamental aspect is the fact that objects at infinity can be represented and manipulated with projective geometry and this in contrast to the Euclidean geometry. This allows perspective deformations to be represented as projective transformations. Figure 1.1: Example of perspective deformation or 2D projective transforma- tion. Another argument is that Euclidean geometry is sometimes difficult to use in algorithms, with particular cases arising from non-generic situations (e.g.
    [Show full text]
  • Chapter 12 the Cross Ratio
    Chapter 12 The cross ratio Math 4520, Fall 2017 We have studied the collineations of a projective plane, the automorphisms of the underlying field, the linear functions of Affine geometry, etc. We have been led to these ideas by various problems at hand, but let us step back and take a look at one important point of view of the big picture. 12.1 Klein's Erlanger program In 1872, Felix Klein, one of the leading mathematicians and geometers of his day, in the city of Erlanger, took the following point of view as to what the role of geometry was in mathematics. This is from his \Recent trends in geometric research." Let there be given a manifold and in it a group of transforma- tions; it is our task to investigate those properties of a figure belonging to the manifold that are not changed by the transfor- mation of the group. So our purpose is clear. Choose the group of transformations that you are interested in, and then hunt for the \invariants" that are relevant. This search for invariants has proved very fruitful and useful since the time of Klein for many areas of mathematics, not just classical geometry. In some case the invariants have turned out to be simple polynomials or rational functions, such as the case with the cross ratio. In other cases the invariants were groups themselves, such as homology groups in the case of algebraic topology. 12.2 The projective line In Chapter 11 we saw that the collineations of a projective plane come in two \species," projectivities and field automorphisms.
    [Show full text]
  • Single View Geometry Camera Model & Orientation + Position Estimation
    Single View Geometry Camera model & Orientation + Position estimation What am I? Vanishing point Mapping from 3D to 2D Point & Line Goal: Homogeneous coordinates Point – represent coordinates in 2 dimensions with a 3-vector &x# &x# homogeneous coords $y! $ ! ''''''→$ ! %y" %$1"! The projective plane • Why do we need homogeneous coordinates? – represent points at infinity, homographies, perspective projection, multi-view relationships • What is the geometric intuition? – a point in the image is a ray in projective space y (sx,sy,s) (x,y,1) (0,0,0) z x image plane • Each point (x,y) on the plane is represented by a ray (sx,sy,s) – all points on the ray are equivalent: (x, y, 1) ≅ (sx, sy, s) Projective Lines Projective lines • What does a line in the image correspond to in projective space? • A line is a plane of rays through origin – all rays (x,y,z) satisfying: ax + by + cz = 0 ⎡x⎤ in vector notation : 0 a b c ⎢y⎥ = [ ]⎢ ⎥ ⎣⎢z⎦⎥ l p • A line is also represented as a homogeneous 3-vector l Line Representation • a line is • is the distance from the origin to the line • is the norm direction of the line • It can also be written as Example of Line Example of Line (2) 0.42*pi Homogeneous representation Line in Is represented by a point in : But correspondence of line to point is not unique We define set of equivalence class of vectors in R^3 - (0,0,0) As projective space Projective lines from two points Line passing through two points Two points: x Define a line l is the line passing two points Proof: Line passing through two points • More
    [Show full text]
  • 6. the Riemann Sphere It Is Sometimes Convenient to Add a Point at Infinity ∞ to the Usual Complex Plane to Get the Extended Complex Plane
    6. The Riemann sphere It is sometimes convenient to add a point at infinity 1 to the usual complex plane to get the extended complex plane. Definition 6.1. The extended complex plane, denoted P1, is simply the union of C and the point at infinity. It is somewhat curious that when we add points at infinity to the reals we add two points ±∞ but only only one point for the complex numbers. It is rare in geometry that things get easier as you increase the dimension. One very good way to understand the extended complex plane is to realise that P1 is naturally in bijection with the unit sphere: Definition 6.2. The Riemann sphere is the unit sphere in R3: 2 3 2 2 2 S = f (x; y; z) 2 R j x + y + z = 1 g: To make a correspondence with the sphere and the plane is simply to make a map (a real map not a function). We define a function 2 3 F : S − f(0; 0; 1)g −! C ⊂ R as follows. Pick a point q = (x; y; z) 2 S2, a point of the unit sphere, other than the north pole p = N = (0; 0; 1). Connect the point p to the point q by a line. This line will meet the plane z = 0, 2 f (x; y; 0) j (x; y) 2 R g in a unique point r. We then identify r with a point F (q) = x + iy 2 C in the usual way. F is called stereographic projection.
    [Show full text]
  • Euclidean Versus Projective Geometry
    Projective Geometry Projective Geometry Euclidean versus Projective Geometry n Euclidean geometry describes shapes “as they are” – Properties of objects that are unchanged by rigid motions » Lengths » Angles » Parallelism n Projective geometry describes objects “as they appear” – Lengths, angles, parallelism become “distorted” when we look at objects – Mathematical model for how images of the 3D world are formed. Projective Geometry Overview n Tools of algebraic geometry n Informal description of projective geometry in a plane n Descriptions of lines and points n Points at infinity and line at infinity n Projective transformations, projectivity matrix n Example of application n Special projectivities: affine transforms, similarities, Euclidean transforms n Cross-ratio invariance for points, lines, planes Projective Geometry Tools of Algebraic Geometry 1 n Plane passing through origin and perpendicular to vector n = (a,b,c) is locus of points x = ( x 1 , x 2 , x 3 ) such that n · x = 0 => a x1 + b x2 + c x3 = 0 n Plane through origin is completely defined by (a,b,c) x3 x = (x1, x2 , x3 ) x2 O x1 n = (a,b,c) Projective Geometry Tools of Algebraic Geometry 2 n A vector parallel to intersection of 2 planes ( a , b , c ) and (a',b',c') is obtained by cross-product (a'',b'',c'') = (a,b,c)´(a',b',c') (a'',b'',c'') O (a,b,c) (a',b',c') Projective Geometry Tools of Algebraic Geometry 3 n Plane passing through two points x and x’ is defined by (a,b,c) = x´ x' x = (x1, x2 , x3 ) x'= (x1 ', x2 ', x3 ') O (a,b,c) Projective Geometry Projective Geometry
    [Show full text]
  • 1 Affine and Projective Coordinate Notation 2 Transformations
    CS348a: Computer Graphics Handout #9 Geometric Modeling Original Handout #9 Stanford University Tuesday, 3 November 1992 Original Lecture #2: 6 October 1992 Topics: Coordinates and Transformations Scribe: Steve Farris 1 Affine and Projective Coordinate Notation Recall that we have chosen to denote the point with Cartesian coordinates (X,Y) in affine coordinates as (1;X,Y). Also, we denote the line with implicit equation a + bX + cY = 0as the triple of coefficients [a;b,c]. For example, the line Y = mX + r is denoted by [r;m,−1],or equivalently [−r;−m,1]. In three dimensions, points are denoted by (1;X,Y,Z) and planes are denoted by [a;b,c,d]. This transfer of dimension is natural for all dimensions. The geometry of the line — that is, of one dimension — is a little strange, in that hyper- planes are points. For example, the hyperplane with coefficients [3;7], which represents all solutions of the equation 3 + 7X = 0, is the same as the point X = −3/7, which we write in ( −3) coordinates as 1; 7 . 2 Transformations 2.1 Affine Transformations of a line Suppose F(X) := a + bX and G(X) := c + dX, and that we want to compose these functions. One way to write the two possible compositions is: G(F(X)) = c + d(a + bX)=(c + da)+bdX and F(G(X)) = a + b(c + d)X =(a + bc)+bdX. Note that it makes a difference which function we apply first, F or G. When writing the compositions above, we used prefix notation, that is, we wrote the func- tion on the left and its argument on the right.
    [Show full text]
  • Dirichlet Problem at Infinity for P-Harmonic Functions on Negatively
    CORE Metadata, citation and similar papers at core.ac.uk Provided by Helsingin yliopiston digitaalinen arkisto Dirichlet problem at infinity for p-harmonic functions on negatively curved spaces Aleksi Vähäkangas Department of Mathematics and Statistics Faculty of Science University of Helsinki 2008 Academic dissertation To be presented for public examination with the permission of the Faculty of Science of the University of Helsinki in Auditorium XIII of the University Main Building on 13 December 2008 at 10 a.m. ISBN 978-952-92-4874-2 (pbk) Helsinki University Print ISBN 978-952-10-5170-8 (PDF) http://ethesis.helsinki.fi/ Helsinki 2008 Acknowledgements I am in greatly indebted to my advisor Ilkka Holopainen for his continual support and encouragement. His input into all aspects of writing this thesis has been invaluable to me. I would also like to thank the staff and students at Kumpula for many interesting discussions in mathematics. The financial support of the Academy of Finland and the Graduate School in Mathe- matical Analysis and Its Applications is gratefully acknowledged. Finally, I would like to thank my brother Antti for advice and help with this work and my parents Simo and Anna-Kaisa for support. Helsinki, September 2008 Aleksi Vähäkangas List of included articles This thesis consists of an introductory part and the following three articles: [A] A. Vähäkangas: Dirichlet problem at infinity for A-harmonic functions. Potential Anal. 27 (2007), 27–44. [B] I. Holopainen and A. Vähäkangas: Asymptotic Dirichlet problem on negatively curved spaces. Proceedings of the International Conference on Geometric Function Theory, Special Functions and Applications (ICGFT) (R.
    [Show full text]
  • Manifolds Without Conjugate Points
    MANIFOLDS WITHOUT CONJUGATE POINTS BY MARSTON MORSE AND GUSTAV A. HEDLUND 1. Introduction. If a closed two-dimensional Riemannian manifold M is homeomorphic to a sphere or to the projective plane and A is any point of M, there exists a geodesic passing through A with a point on it conjugate to A (cf., e.g., Myers [l, p. 48, Corollary 2])(l). There exists a closed two-dimen- sional Riemannian manifold of any other given topological type such that no geodesic on the manifold has on it two mutually conjugate points. The sim- plest examples of these are manifolds of vanishing Gaussian curvature in the case of the torus and the Klein bottle, and manifolds of constant negative curvature in the remaining cases. In all these particular examples the differ- ential equations defining the geodesies can be integrated and the properties in the large of the geodesies can be determined. In the case of the flat torus or flat Klein bottle the geodesies are either periodic or recurrent but not periodic. In the case of closed manifolds of constant negative curvature the behavior of the geodesies is much more complex, but among other types there exist transitive geodesies. In this paper our starting point will be the assumption that we have a closed two-dimensional Riemannian manifold M such that no geodesic on M has on it two mutually conjugate points. Our aim is to determine what prop- erties of M or of the geodesies on M must follow from this hypothesis. The possibility that M be homeomorphic to the sphere or to the projective plane is thereby eliminated and it is necessary to divide the possible closed mani- folds into two classes.
    [Show full text]
  • 4 Lines and Cross Ratios
    4 Lines and cross ratios At this stage of this monograph we enter a significant didactic problem. There are three concepts which are intimately related and which unfold their full power only if they play together. These concepts are performing calculations with geometric objects, determinants and determinant algebra and geometric incidence theorems. The reader may excuse that in a beginners book that makes only little assumptions on the pre-knowledge one has to introduce these concepts one after the other. Thereby we will sacrifice some mathe- matical beauty for clearness of exposition. Still we highly recommend to read the following chapters (at least) twice. In order to get an impression of the interplay of the different concepts. This and the next section is devoted to the relations of RP2 to calcula- tions in the underlying field R. For this we will first find methods to relate points in a projective plane to the coordinates over R. Then we will show that elementary operations like addition and multiplication can be mimicked in a purely geometric fashion. Finally we will use these facts to derive in- teresting statements about the structure of projective planes and projective transformations. 4.1 Coordinates on a line Assume that two distinct points [p] and [q] in R are given. How can we describe the set of all points on the line throughP these two points. It is clear that we can implicitly describe them by first calculating the homogeneous coordinates of the line through p and q and then selecting all points that are incident to this line.
    [Show full text]
  • Lecture 2.2 a Brief Introduction to Projective Geometry
    Lecture 1.3 Basic projective geometry Thomas Opsahl Motivation • For the pinhole camera, the correspondence between observed 3D points in the world and 2D points in the captured image is given by straight lines through a common point (pinhole) • This correspondence can be described by a mathematical model known as “the perspective camera model” or “the pinhole camera model” • This model can be used to describe the imaging geometry of many modern cameras, hence it plays a central part in computer vision 2 Motivation • Before we can study the perspective camera model in detail, we need to expand our mathematical toolbox • We need to be able to mathematically describe the position and orientation of the camera relative to the world coordinate frame • Also we need to get familiar with some basic elements of projective geometry, since this will make it MUCH easier to describe and work with the perspective camera model 3 Introduction • We have seen that the pose of a coordinate frame relative to a coordinate frame , denoted , can be represented as a homogeneous transformation in 2D rrA t AAR t 11 12 Bx AAξ = BB= A∈ B TB r21 r 22 tBx SE (2) 0 1 00 1 Introduction • We have seen that the pose of a coordinate frame relative to a coordinate frame , denoted , can be represented as a homogeneous transformation in 2D and 3D rrrA t 11 12 13 Bx AARt rrrA t AAξ T = BB = 21 22 23 By ∈ SE (3) BBA 0 1 rrr31 32 33 tBz 000 1 Introduction • And we have seen how they can transform points from one reference frame to another if we represent
    [Show full text]
  • A the Riemann Sphere
    MATH 132 (19F) (TA) A. Zhou Complex Analysis for Applications A THE RIEMANN SPHERE A.1 STEREOGRAPHIC PROJECTION The points of the complex plane can be (mostly) associated with points on the sphere. To make 2 2 2 2 3 this more precise, consider the unit sphere S = (x1; x2; x3) x1 + x2 + x3 = 1 sitting in R , and identify the plane x3 = 0 with the complex plane C via (x1; x2; 0) $ x1 + x2i. Let N = (0; 0; 1) denote the north pole of the unit sphere. Given a point P 2 S2 with P 6= N, we obtain a complex 3 number φN (P ) by intersecting line NP with C ⊂ R . Definition A.1.1: Stereographic projection 2 The map P 7! φN (P ) from S nfNg to C is stereographic projection through the north pole. This map is invertible, with inverse given by taking a complex number z, drawing the line through N and z, and taking the intersection point of this line with S2 that is not N. The inverse map is also called stereographic projection; it will be clear from context which direction is meant. 2 Given P = (x1; x2; x3) 2 S with P 6= N, the line NP has parametric form (tx1; tx2; tx3 + (1 − t)). This intersects C when tx3 + (1 − t) = 0, so t = 1=(1 − x3). (This is defined, because P 6= N means that x3 6= 1.) It thus follows that x1 x2 φN (P ) = + · i: (A.1) 1 − x3 1 − x3 −1 For the inverse map, let z = x + yi 2 C.
    [Show full text]
  • Projective Geometry
    REFLECTIONS Projective Geometry S Ramanan The following is a write-up of a talk that was presented at the TIFR as part of the Golden Jubilee celebrations of that Institute during 1996. Introduction For some reason not so well understood, mathematicians find it most difficult to communicate their joys and frustrations, their insights and experiences to the general public, indeed even to other fellow scientists! Perhaps this is due to the fact that mathematicians are trained to use very precise language, and so find it hard to simplify and state something not entirely correct. You mqst have heard of the gentleman who while he was drowning, exclaimed, "Oh! Lord, if You exist! Help me, if You can!" I am sure it was a mathematician. On the other hand, mathematics carries a certain mystique for most non-mathematicians. It is one subject to which nobody seems to have been neutral at school. Everyone says, "I loved mathematics at school", or "I hated it". Nobody says it was just one of those subjects. Let me leave it to psychologists to analyse why it is so and get on with my subject matter. With some concessions on your part for some resultant vagueness, I will try to communicate some ideas basic to the topic which I have been interested in for a considerable percentage of my professional life, namely, Projective Geometry. Perspective Mathematical theories are, by and large, off-shoots of applications and not precursors. Whatever the validity of such a general formulation, it is certainly true of Projective Geometry. The first seeds of this theory may be seen in the attempt to understand perspective in painting.
    [Show full text]