Linear Subspaces - Geometry No Invariants, so Capture Variation • Each image = a pt. in a high-dimensional space. – Image: Each pixel a dimension. – Point set: Each coordinate of each pt. A dimension. • Simplest rep. of variation is linear. – Basis (eigen) images: x1…xk – Each image, x = a1x1 + … + akxk • Useful if k << n. When is this accurate? • Approximately right when: – Variation approximately linear. Always true for small variation. – Some variations big, some small, can discard small. • Exactly right sometimes. – Point features with scaled-orthographic projection. – Convex, Lambertian objects and distant lights. Principal Components Analysis (PCA) • All-purpose linear approximation. • Given images (as vectors) • Finds low-dimensional linear subspace that best approximates them. – Eg., minimizes distance from images to subspace. Derivation on whiteboard • This is all taken from Duda, Hart and Stork Pattern Classification pp. 114-117. Excerpt in library. SVD • Scatter matrix can be big, so computation non-trivial. • Stack data into matrix X, each row an image. SVD gives X = UDVT – D is diagonal with non-increasing values. – U and V have orthonormal rows. • VT(:,1:k) gives first k principal components. • matlab Linear Combinations u v u v . . . u v 1 1 1 1 2 1 2 1 m 1 m 1 u v u v 1 2 . . . 1 2 2 2 u v u 1 n 1 n 2 n 2 v . . . u v . . . u v 2 m 2 n m 2 m 2 n . . I . m n s s s s s s 1 1,1 1 2 ,1 2 1,1 2 2 ,1 m 1,1 m 2 ,1 s s s 1 1, 2 1 2,2 2 1, 2 s . . . s s 2 2,2 m 1, 2 m 2,2 S s s s 1 1, 3 1 2,3 2 1, 3 s 2 2,3 x t y z 1 t t t t t 1 x 1 y 2 x 2 1 y 1 1 s s m 1, 3 m 2,3 x y z 1 2 . . . 2 x y z 1 n n 2 n m x m y P Immediately apparent that u and v coordinates lie in a 4D linear subspace We Can Remove Translation (1) • This is trivial, because we can pick a simple origin. – World origin is arbitrary. – Example: We can assume first point is at origin. • Rotation then doesn’t effect that point. • All its motion is translation. – Better to pick center of mass as origin. • Average of all points. • This also averages all noise. Remove Translation (2) x 0 n i WLOG : y 0 i 1 i 0 z i n u i u k 1 i k u v u v ~ I u v 1 v v k 1 2 1 2 1 1 m 1 i 1 1 m n n 1 u v u 1 v 2 . . . u v 1 u u v v u u 1 v v 2 1 1 2 1 . . . 2 2 m m 2 2 m 2 1 2 2 n m m 2 m n n 2 . . . u u v v 1 n 2 2 1 1 2 2 u u v v u u v v . . . u u v v m n m . . . m m n i k n Notice this is just the first step of PCA. First Step: Remove Translation (3) u~ ~ v u~ ~ v . . . u~ v~ 1 1 2 u~ v~ u~ v~ . . . u~ v~ . . . u~ v~ 1 2 1 1 . . . 1 2 2 1 2 m 1 2 2 n 1 2 2 2 m m n . . . n 1 1,1 1 2 1,1 2 2 ,1 n m s s s s s s 2 ,1 n 2 m 1 n 2 1 1 u~ v~ u~ v~ m m 1,1 m 2 ,1 s 1 1, 2 s s s . . 1 2,2 2 1, 2 2 2,2 . s s m 1, 2 m 2,2 s s s s x y z s s 1 1, 3 1 2,3 2 1, 3 1 x y 1 z 2 2,3 m 1, 3 m 2,3 1 2 2 2 . . . x y z n n n Rank Theorem u~ ~ v u~ ~ v . . . u~ v~ 1 1 2 u~ v~ u~ v~ . . . u~ v~ . . . u~ v~ 1 2 1 1 . . . 1 2 2 1 2 m 1 2 2 1 2 2 2 m m n . . ~ I . n 1 1,1 1 2 1,1 2 2 ,1 n m s s s s s s 2 ,1 n 2 m 1 n n 2 1 1 u~ v~ u~ v~ m m 1,1 m 2 ,1 s 1 1, 2 s s s . . 1 2,2 2 1, 2 2 2,2 . s s m 1, 2 m 2,2 s s s s x y z s s 1 1, 3 1 2,3 2 1, 3 1 x y 1 z 2 2,3 m 1, 3 1 2 . 2 . . x y z n n 2 n P m 2,3 S So, given any object, u and v coordinates of any image of it lie in a 3-dimensional linear subspace. ~ I has rank 3. This means there are 3 vectors such that every ~ row of I is a linear combination of these vectors. These vectors are the rows of P. Lower-Dimensional Subspace • (a4,b4) affine invariant coordinates of point 4 relative to first three. • Represent image: (a4,b4, a5,b5,… an,bn) – This representation is complete. – The a or b coordinates of all images of an object occupy a 1D linear subspace. Representation is Complete s s s s 1,1 1, 2 2 ,1 2,2 s s t t 1, 3 2,3 x y a P a 1,1 2 ,1 a a 1, 2 2,2 t t r r 0 1,1 x 2 ,1 y r r 0 1, 2 2,2 r r 0 1, 3 2,3 0 0P 1 where (r , r , r ) (r , r , r ) 0 1,1 1, 2 1, 3 2 ,1 2,2 2,3 (r , r , r ) (r , r , r ) 1 1,1 1, 2 1, 3 2 ,1 2,2 2,3 • 3D-2D affine transformation is projection in some direction + 2D-2D affine transformation. • 2D-2D affine maps first three image points anywhere. So they’re irrelevant to a complete representation. • Once we use only affine coordinates, 2D-2D affine transformation no longer matters. 1D Subspace Summary • Projection can be linearized. • So images produced under projection can be linear and low-dimensional. • Are these results relevant to surfaces of real 3D objects projected to 2D? – Maybe to features; probably not to intensity images. • Why would images of a class of objects be low-dimensional?