1 Introduction to Computer Vision Week 11, Fall 2010 Instructor: Prof. Ko Nishino
2 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 (0,0,0) z y x (x,y,1) image plane (sx,sy,s) 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)
3 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 [ ] in vector notation : 0 = a b c x y z A line is also represented as a homogeneous 3-vector l l p
4 Point and Line Duality A line l is a homogeneous 3-vector It is to every point (ray) p on the line: l p=0 l p 1 p 2 l 1 p l 2 What is the line l spanned by rays p 1 and p 2? l is to p 1 and p 2 l = p 1 p 2 l is the plane normal What is the intersection of two lines l 1 and l 2? p is to l 1 and l 2 p = l 1 l 2 Points and lines are dual in projective space given any formula, can switch the meanings of points and lines to get another formula
5 Ideal Points and Lines y (sx,sy,0) y z x (0,0,1) image plane z Ideal point ( point at infinity ) p (x, y, 0) parallel to image plane Infinitely large coordinates Ideal line l (0,0,1) parallel to image plane x image plane
6 Homographies of Points and Lines Computed by 3x3 matrix multiplication To transform a point: p = Hp To transform a line: lp=0 l p =0 0 = lp = lh -1 Hp = lh -1 p l = lh -1 lines are transformed by postmultiplication of H -1
7 3D Projective Geometry These concepts generalize naturally to 3D Homogeneous coordinates Projective 3D points have four coords: P = (X,Y,Z,W) Duality A plane N is also represented by a 4-vector Points and planes are dual in 3D: N P=0 Projective transformations Represented by 4x4 matrices T: P = TP, N = N T -1
8 Vanishing Points image plane vanishing point camera center Vanishing point ground plane projection of a point at infinity
9 Vanishing Points (2D) image plane vanishing point camera center line on ground plane
10 Vanishing Points image plane vanishing point V camera center C line on ground plane Properties line on ground plane Any two parallel lines have the same vanishing point v The ray from C through v is parallel to the lines An image may have more than one vanishing point
11 Vanishing points Image by Q-T. Luong (a vision researcher & photographer)
12 Vanishing Lines v 1 v 2 Multiple Vanishing Points Any set of parallel lines on the plane define a vanishing point The union of all of these vanishing points is the horizon line (also called vanishing line) Note that different planes define different vanishing lines
13 Vanishing Lines Multiple Vanishing Points Any set of parallel lines on the plane define a vanishing point The union of all of these vanishing points is the horizon line (also called vanishing line) Note that different planes define different vanishing lines
14 Vanishing Lines Image by Q-T. Luong (a vision researcher & photographer)
15 Computing Vanishing Points V P 0 D P is a point at infinity, v is its projection They depend only on line direction Parallel lines P 0 + td, P 1 + td intersect at P
16 Computing Vanishing Lines C l ground plane l is the intersection of horizontal plane through C with image plane Compute l from two sets of parallel lines on ground plane All points at same height as C project to l points higher than C project above l Provides way of comparing height of objects in the scene
18 Fun with Vanishing Points
19 Recognition Slides courtesy of Professor Steven Seitz
20 Recognition The Margaret Thatcher Illusion, by Peter Thompson!
21 Recognition The George Bush Illusion, by Tania Lombrozo!
22 Recognition Problems What is it? Object detection Who is it? Recognizing identity What are they doing? Activities All of these are classification problems Choose one class from a list of possible candidates
23 Face Detection
24 One Simple Method: Skin Detection R skin! Skin pixels have a distinctive range of colors Corresponds to region(s) in RGB color space for visualization, only R and G components are shown above G Skin classifier A pixel X = (R,G,B) is skin if it is in the skin region But how to find this region?
25 Skin Detection R Learn the skin region from examples Manually label pixels in one or more training images as skin or not skin Plot the training data in RGB space skin pixels shown in orange, non-skin pixels shown in blue some skin pixels may be outside the region, non-skin pixels inside. Skin classifier Given X = (R,G,B): how to determine if it is skin or not? G
26 Skin Classification Techniques R Skin classifier Given X = (R,G,B): how to determine if it is skin or not? Nearest neighbor find labeled pixel closest to X choose the label for that pixel Data modeling fit a model (curve, surface, or volume) to each class Probabilistic data modeling fit a probability model to each class G
27 Probability Basic probability X is a random variable P(X) is the probability that X achieves a certain value called a PDF! - probability distribution/density function! - a 2D PDF is a surface, 3D PDF is a volume! or continuous X! discrete X! Conditional probability: P(X Y) probability of X given that we already know Y
28 Probabilistic Skin Classification T h Now we can model uncertainty Each pixel has a probability of being skin or not skin Skin classifier Given X = (R,G,B): how to determine if it is skin or not? Choose interpretation of highest probability set X to be a skin pixel if and only if Where do we get and?
29 Learning Conditional PDF s We can calculate P(R skin) from a set of training images It is simply a histogram over the pixels in the training images each bin R i contains the proportion of skin pixels with color R i But this isn t quite what we want Why not? How to determine if a pixel is skin? We want P(skin R) not P(R skin) How can we get it?
30 Bayes Rule In terms of our problem: what we measure! (likelihood)! domain knowledge! (prior) what we want! (posterior)! normalization term! What could we use for the prior P(skin)? Could use domain knowledge P(skin) may be larger if we know the image contains a person for a portrait, P(skin) may be higher for pixels in the center Could learn the prior from the training set. How? P(skin) may be proportion of skin pixels in training set
31 Bayesian Estimation T h T h likelihood! posterior (unnormalized)! Bayesian estimation = minimize probability of misclassification Goal is to choose the label (skin or ~skin) that maximizes the posterior (Maximum A Posteriori (MAP) estimation) Suppose the prior is uniform: P(skin) = P(~skin) = in this case, 0.5! maximizing the posterior is equivalent to maximizing the likelihood (Maximum Likelihood (ML) estimation) if and only if
32 Skin Detection Results
33 General Classification This same procedure applies in more general circumstances More than two classes More than one dimension Example: face detection Here, X is an image region dimension = # pixels each face can be thought of as a point in a high dimensional space H. Schneiderman, T. Kanade. "A Statistical Method for 3D Object Detection Applied to Faces and Cars". IEEE Conference on Computer Vision and Pattern Recognition (CVPR 2000) H. Schneiderman and T.Kanade!
34 Linear Subspaces convert x into v 1, v 2 coordinates! What does the v 2 coordinate measure?! - distance to line! - use it for classification near 0 for orange pts! What does the v 1 coordinate measure?! - position along line! - use it to specify which orange point it is! Classification can be expensive Must either search (e.g., nearest neighbors) or store large PDF s Suppose the data points are arranged as above Idea fit a line, classifier measures distance to line
35 Dimensionality Reduction Dimensionality reduction We can represent the orange points with only their v 1 coordinates since v 2 coordinates are all essentially 0 This makes it much cheaper to store and compare points A bigger deal for higher dimensional problems
36 Linear Subspaces Consider the variation along direction v among all of the orange points:! What unit vector v minimizes var?! What unit vector v maximizes var?! Solution:!v 1 is eigenvector of A with largest eigenvalue!!v 2 is eigenvector of A with smallest eigenvalue!
37 Principal Component Analysis Suppose each data point is N-dimensional Same procedure applies: The eigenvectors of A define a new coordinate system eigenvector with largest eigenvalue captures the most variation among training vectors x eigenvector with smallest eigenvalue has least variation We can compress the data by only using the top few eigenvectors corresponds to choosing a linear subspace represent points on a line, plane, or hyper-plane these eigenvectors are known as the principal components
38 The Space of Faces = + An image is a point in a high dimensional space An N x M image is a point in R NM We can define vectors in this space as we did in the 2D case
39 Dimensionality Reduction The set of faces is a subspace of the set of images Suppose it is K dimensional We can find the best subspace using PCA This is like fitting a hyper-plane to the set of faces spanned by vectors v 1, v 2,..., v K any face
40 Eigenfaces PCA extracts the eigenvectors of A Gives a set of vectors v 1, v 2, v 3,... Each one of these vectors is a direction in face space T what do these look like? h e T h e T h e
41 Projecting onto the Eigenfaces The eigenfaces v 1,..., v K span the space of faces A face is converted to eigenface coordinates by The image part with The image part with The image part with The image part with The image part with The image part with The image part with The image part with
42 Recognition with Eigenfaces Algorithm 1. Process the image database (set of images with labels) Run PCA compute eigenfaces Calculate the K coefficients for each image 2. Given a new image (to be recognized) x, calculate K coefficients 3. Detect if x is a face 4. If it is a face, who is it? Find closest labeled face in database nearest-neighbor in K-dimensional space
43 Choosing the Dimension K eigenvalues i = K NM How many eigenfaces to use? Look at the decay of the eigenvalues the eigenvalue tells you the amount of variance in the direction of that eigenface ignore eigenfaces with low variance
44 Object Recognition This is just the tip of the iceberg We ve talked about using pixel color as a feature Many other features can be used: edges motion (e.g., optical flow) object size SIFT... Classical object recognition techniques recover 3D information as well given an image and a database of 3D models, determine which model(s) appears in that image often recover 3D pose of the object as well
46 Image Formation/Sensing Pin-hole model Thin-lens law Aperture Depth of field Radiometric/Geometric distortion Human eyes Sensors Quantum efficiency Sensing color
47 Camera Models and Projective Geometry Homogeneous coordinates and their geometric intuition Projection models Perspective, orthographic, weak-perspective, and affine Camera calibration Camera parameters Direct linear method Homography Points and lines in projective space projective operations: line intersection, line containing two points ideal points and lines (at infinity) Vanishing points and lines and how to compute them
48 Image Filtering Digital vs. continuous images Linear shift invariant systems Convolution Sifting property Cascade system Fourier transform Convolution Gaussian smoothing Sampling theorem Nyquist law Aliasing Smoothing Gaussian filtering Median filtering Image scaling Image resampling Correlation
49 Edge Detection Origin of edges Edge types Theory of edge detection Squared gradient Laplacian Discrete approximations Accounting for noise Derivative theorem of convolution Laplacian of Gaussian Canny edge detector Difference of Gaussians
50 Motion Optical flow problem definition Motion field and optical flow Aperture problem and how it arises Assumptions Brightness constancy, small motion, smoothness Derivation of optical flow constraint equation Lucas-Kanade equation Derivation Conditions for solvability Meanings of eigenvalues and eigenvectors Iterative refinement Newton s method Pyramid-based flow estimation
51 Mosaicing Wide-angle imaging Cylindrical image reprojection Accounting for radial distortion Brightness constancy, small motion, smoothness Drifting
52 Lightness Color constancy Lightness recovery Frequency domain interpretation Solving Poisson equation Lightness from multiple images
53 Radiometry and Reflectance Describing light Optics Radiometric concepts Solid angle Radiant intensity Irradiance Radiance Radiometric image formation Scene radiance to image irradiance BRDF Surface irradiance to surface radiance Properties Reflection Body reflection and surface reflection Diffuse reflection and specular reflection Reflectance models Lambertian Ideal specular Torrance-Sparrow Dichromatic reflectance model
54 Photometric Stereo Gradient space Reflectance map Diffuse photometric stereo derivation equations solving for albedo, normals depths from normals Handling shadows Computing light source directions from a shiny ball Limitations
55 Shape-from-Shading Stereographic projection Smoothness constraint Calculus of variations Numerical shape-from-shading
56 Stereo Visual cues for 3D inference Disparity and depth Vergence Epipolar geometry Epipolar plane/line Fundamental matrix Stereo image rectification Stereo matching window-based matching effect of window size sources of error Active stereo (basic idea) structured light laser scanning
57 Structure-from-Motion Factorization method Problem formulation Rank constraint SVD Resolve ambiguity
58 Recognition Classifiers Probabilistic classification Decision boundaries Learning PDF s from training images Bayes law Maximum likelihood MAP Principal component analysis Eigenfaces algorithm
59 Fin! Don t bomb the final exam Closed book COMPREHENSIVE! Here, same time next week