Presentation is loading. Please wait.

Presentation is loading. Please wait.

Template matching and object recognition. CS8690 Computer Vision University of Missouri at Columbia Recognition by finding patterns We have seen very.

Similar presentations


Presentation on theme: "Template matching and object recognition. CS8690 Computer Vision University of Missouri at Columbia Recognition by finding patterns We have seen very."— Presentation transcript:

1 Template matching and object recognition

2 CS8690 Computer Vision University of Missouri at Columbia Recognition by finding patterns We have seen very simple template matching (under filters) Some objects behave like quite simple templates –Frontal faces We have seen very simple template matching (under filters) Some objects behave like quite simple templates –Frontal faces Strategy: –Find image windows –Correct lighting –Pass them to a statistical test (a classifier) that accepts faces and rejects non-faces

3 CS8690 Computer Vision University of Missouri at Columbia Basic ideas in classifiers Loss –some errors may be more expensive than others e.g. a fatal disease that is easily cured by a cheap medicine with no side-effects -> false positives in diagnosis are better than false negatives –We discuss two class classification: L(1->2) is the loss caused by calling 1 a 2 Total risk of using classifier s Loss –some errors may be more expensive than others e.g. a fatal disease that is easily cured by a cheap medicine with no side-effects -> false positives in diagnosis are better than false negatives –We discuss two class classification: L(1->2) is the loss caused by calling 1 a 2 Total risk of using classifier s

4 CS8690 Computer Vision University of Missouri at Columbia Basic ideas in classifiers Generally, we should classify as 1 if the expected loss of classifying as 1 is better than for 2 gives Crucial notion: Decision boundary –points where the loss is the same for either case Generally, we should classify as 1 if the expected loss of classifying as 1 is better than for 2 gives Crucial notion: Decision boundary –points where the loss is the same for either case 1 if 2 if

5 CS8690 Computer Vision University of Missouri at Columbia Some loss may be inevitable: the minimum risk (shaded area) is called the Bayes risk

6 CS8690 Computer Vision University of Missouri at Columbia Finding a decision boundary is not the same as modelling a conditional density.

7 CS8690 Computer Vision University of Missouri at Columbia Assume normal class densities, p-dimensional measurements with common (known) covariance and different (known) means Class priors are Can ignore a common factor in posteriors - important; posteriors are then: Assume normal class densities, p-dimensional measurements with common (known) covariance and different (known) means Class priors are Can ignore a common factor in posteriors - important; posteriors are then: Example: known distributions

8 CS8690 Computer Vision University of Missouri at Columbia Classifier boils down to: choose class that minimizes: because covariance is common, this simplifies to sign of a linear expression (i.e. Voronoi diagram in 2D for  =I and equal priors) Mahalanobis distance

9 CS8690 Computer Vision University of Missouri at Columbia Plug-in classifiers Assume that distributions have some parametric form - now estimate the parameters from the data. Common: –assume a normal distribution with shared covariance, different means; use usual estimates –ditto, but different covariances; ditto Issue: parameter estimates that are “good” may not give optimal classifiers. Assume that distributions have some parametric form - now estimate the parameters from the data. Common: –assume a normal distribution with shared covariance, different means; use usual estimates –ditto, but different covariances; ditto Issue: parameter estimates that are “good” may not give optimal classifiers.

10 CS8690 Computer Vision University of Missouri at Columbia Histogram based classifiers Use a histogram to represent the class- conditional densities –(i.e. p(x|1), p(x|2), etc) Advantage: estimates become quite good with enough data! Disadvantage: Histogram becomes big with high dimension –but maybe we can assume feature independence? Use a histogram to represent the class- conditional densities –(i.e. p(x|1), p(x|2), etc) Advantage: estimates become quite good with enough data! Disadvantage: Histogram becomes big with high dimension –but maybe we can assume feature independence?

11 CS8690 Computer Vision University of Missouri at Columbia Finding skin Skin has a very small range of (intensity independent) colours, and little texture –Compute an intensity-independent colour measure, check if colour is in this range, check if there is little texture (median filter) –See this as a classifier - we can set up the tests by hand, or learn them. –get class conditional densities (histograms), priors from data (counting) Classifier is Skin has a very small range of (intensity independent) colours, and little texture –Compute an intensity-independent colour measure, check if colour is in this range, check if there is little texture (median filter) –See this as a classifier - we can set up the tests by hand, or learn them. –get class conditional densities (histograms), priors from data (counting) Classifier is

12 CS8690 Computer Vision University of Missouri at Columbia Figure from “Statistical color models with application to skin detection,” M.J. Jones and J. Rehg, Proc. Computer Vision and Pattern Recognition, 1999 copyright 1999, IEEE

13 CS8690 Computer Vision University of Missouri at Columbia Figure from “Statistical color models with application to skin detection,” M.J. Jones and J. Rehg, Proc. Computer Vision and Pattern Recognition, 1999 copyright 1999, IEEE Receiver Operating Curve

14 CS8690 Computer Vision University of Missouri at Columbia Finding faces Faces “look like” templates (at least when they’re frontal). General strategy: –search image windows at a range of scales –Correct for illumination –Present corrected window to classifier Faces “look like” templates (at least when they’re frontal). General strategy: –search image windows at a range of scales –Correct for illumination –Present corrected window to classifier Issues –How corrected? –What features? –What classifier? –what about lateral views?

15 CS8690 Computer Vision University of Missouri at Columbia Naive Bayes (Important: naive not necessarily pejorative) Find faces by vector quantizing image patches, then computing a histogram of patch types within a face Histogram doesn’t work when there are too many features –features are the patch types –assume they’re independent and cross fingers –reduction in degrees of freedom –very effective for face finders why? probably because the examples that would present real problems aren’t frequent. (Important: naive not necessarily pejorative) Find faces by vector quantizing image patches, then computing a histogram of patch types within a face Histogram doesn’t work when there are too many features –features are the patch types –assume they’re independent and cross fingers –reduction in degrees of freedom –very effective for face finders why? probably because the examples that would present real problems aren’t frequent. Many face finders on the face detection home page http://home.t-online.de/home/Robert.Frischholz/face.htm

16 CS8690 Computer Vision University of Missouri at Columbia Figure from A Statistical Method for 3D Object Detection Applied to Faces and Cars, H. Schneiderman and T. Kanade, Proc. Computer Vision and Pattern Recognition, 2000, copyright 2000, IEEE

17 CS8690 Computer Vision University of Missouri at Columbia Face Recognition Whose face is this? (perhaps in a mugshot) Issue: –What differences are important and what not? –Reduce the dimension of the images, while maintaining the “important” differences. One strategy: –Principal components analysis Whose face is this? (perhaps in a mugshot) Issue: –What differences are important and what not? –Reduce the dimension of the images, while maintaining the “important” differences. One strategy: –Principal components analysis

18 CS8690 Computer Vision University of Missouri at Columbia Template matching Simple cross-correlation between images Best match wins Computationally expensive, i.e. requires presented image to be correlated with every image in the database ! Simple cross-correlation between images Best match wins Computationally expensive, i.e. requires presented image to be correlated with every image in the database !

19 CS8690 Computer Vision University of Missouri at Columbia Eigenspace matching Consider PCA Then, Consider PCA Then, Much cheaper to compute!

20 CS8690 Computer Vision University of Missouri at Columbia

21 CS8690 Computer Vision University of Missouri at Columbia Eigenfaces plus a linear combination of eigenfaces

22 CS8690 Computer Vision University of Missouri at Columbia

23 CS8690 Computer Vision University of Missouri at Columbia Difficulties with PCA Projection may suppress important detail –smallest variance directions may not be unimportant Method does not take discriminative task into account –typically, we wish to compute features that allow good discrimination –not the same as largest variance Projection may suppress important detail –smallest variance directions may not be unimportant Method does not take discriminative task into account –typically, we wish to compute features that allow good discrimination –not the same as largest variance

24 CS8690 Computer Vision University of Missouri at Columbia

25 CS8690 Computer Vision University of Missouri at Columbia Linear Discriminant Analysis We wish to choose linear functions of the features that allow good discrimination. –Assume class-conditional covariances are the same –Want linear feature that maximises the spread of class means for a fixed within-class variance We wish to choose linear functions of the features that allow good discrimination. –Assume class-conditional covariances are the same –Want linear feature that maximises the spread of class means for a fixed within-class variance

26 CS8690 Computer Vision University of Missouri at Columbia

27 CS8690 Computer Vision University of Missouri at Columbia

28 CS8690 Computer Vision University of Missouri at Columbia

29 CS8690 Computer Vision University of Missouri at Columbia Neural networks Linear decision boundaries are useful –but often not very powerful –we seek an easy way to get more complex boundaries Compose linear decision boundaries –i.e. have several linear classifiers, and apply a classifier to their output –a nuisance, because sign(ax+by+cz) etc. isn’t differentiable. –use a smooth “squashing function” in place of sign. Linear decision boundaries are useful –but often not very powerful –we seek an easy way to get more complex boundaries Compose linear decision boundaries –i.e. have several linear classifiers, and apply a classifier to their output –a nuisance, because sign(ax+by+cz) etc. isn’t differentiable. –use a smooth “squashing function” in place of sign.

30 CS8690 Computer Vision University of Missouri at Columbia

31 CS8690 Computer Vision University of Missouri at Columbia

32 CS8690 Computer Vision University of Missouri at Columbia Training Choose parameters to minimize error on training set Stochastic gradient descent, computing gradient using trick (backpropagation, aka the chain rule) Stop when error is low, and hasn’t changed much Choose parameters to minimize error on training set Stochastic gradient descent, computing gradient using trick (backpropagation, aka the chain rule) Stop when error is low, and hasn’t changed much

33 CS8690 Computer Vision University of Missouri at Columbia The vertical face-finding part of Rowley, Baluja and Kanade’s system Figure from “Rotation invariant neural-network based face detection,” H.A. Rowley, S. Baluja and T. Kanade, Proc. Computer Vision and Pattern Recognition, 1998, copyright 1998, IEEE

34 CS8690 Computer Vision University of Missouri at Columbia Histogram equalisation gives an approximate fix for illumination induced variability

35 CS8690 Computer Vision University of Missouri at Columbia Architecture of the complete system: they use another neural net to estimate orientation of the face, then rectify it. They search over scales to find bigger/smaller faces. Figure from “Rotation invariant neural-network based face detection,” H.A. Rowley, S. Baluja and T. Kanade, Proc. Computer Vision and Pattern Recognition, 1998, copyright 1998, IEEE

36 CS8690 Computer Vision University of Missouri at Columbia Figure from “Rotation invariant neural-network based face detection,” H.A. Rowley, S. Baluja and T. Kanade, Proc. Computer Vision and Pattern Recognition, 1998, copyright 1998, IEEE

37 CS8690 Computer Vision University of Missouri at Columbia Convolutional neural networks Template matching using NN classifiers seems to work Natural features are filter outputs –probably, spots and bars, as in texture –but why not learn the filter kernels, too? Template matching using NN classifiers seems to work Natural features are filter outputs –probably, spots and bars, as in texture –but why not learn the filter kernels, too?

38 CS8690 Computer Vision University of Missouri at Columbia Figure from “Gradient-Based Learning Applied to Document Recognition”, Y. Lecun et al Proc. IEEE, 1998 copyright 1998, IEEE A convolutional neural network, LeNet; the layers filter, subsample, filter, subsample, and finally classify based on outputs of this process.

39 CS8690 Computer Vision University of Missouri at Columbia LeNet is used to classify handwritten digits. Notice that the test error rate is not the same as the training error rate, because the test set consists of items not in the training set. Not all classification schemes necessarily have small test error when they have small training error. Figure from “Gradient-Based Learning Applied to Document Recognition”, Y. Lecun et al Proc. IEEE, 1998 copyright 1998, IEEE

40 CS8690 Computer Vision University of Missouri at Columbia Support Vector Machines Neural nets try to build a model of the posterior, p(k|x) Instead, try to obtain the decision boundary directly –potentially easier, because we need to encode only the geometry of the boundary, not any irrelevant wiggles in the posterior. –Not all points affect the decision boundary Neural nets try to build a model of the posterior, p(k|x) Instead, try to obtain the decision boundary directly –potentially easier, because we need to encode only the geometry of the boundary, not any irrelevant wiggles in the posterior. –Not all points affect the decision boundary

41 CS8690 Computer Vision University of Missouri at Columbia Support Vector Machines Neural nets try to build a model of the posterior, p(k|x) Instead, try to obtain the decision boundary directly –potentially easier, because we need to encode only the geometry of the boundary, not any irrelevant wiggles in the posterior. –Not all points affect the decision boundary Neural nets try to build a model of the posterior, p(k|x) Instead, try to obtain the decision boundary directly –potentially easier, because we need to encode only the geometry of the boundary, not any irrelevant wiggles in the posterior. –Not all points affect the decision boundary

42 CS8690 Computer Vision University of Missouri at Columbia

43 CS8690 Computer Vision University of Missouri at Columbia Support Vector Machines Linearly separable data means Choice of hyperplane means Hence distance Linearly separable data means Choice of hyperplane means Hence distance

44 CS8690 Computer Vision University of Missouri at Columbia Support Vector Machines Actually, we construct a dual optimization problem. By being clever about what x means, I can have much more interesting boundaries.

45 CS8690 Computer Vision University of Missouri at Columbia Space in which decision boundary is linear - a conic in the original space has the form

46 CS8690 Computer Vision University of Missouri at Columbia Support Vector Machines Set S of points x i  R n, each x i belongs to one of two classes y i  {-1,1} The goals is to find a hyperplane that divides S in these two classes Set S of points x i  R n, each x i belongs to one of two classes y i  {-1,1} The goals is to find a hyperplane that divides S in these two classes S is separable if  w  R n, b  R Separating hyperplanes didi Closest point

47 CS8690 Computer Vision University of Missouri at Columbia Problem 1: Support Vector Machines Optimal separating hyperplane maximizes Optimal separating hyperplane (OSH) Minimize Subject to support vectors

48 CS8690 Computer Vision University of Missouri at Columbia Solve using Lagrange multipliers Lagrangian –at solution –therefore Lagrangian –at solution –therefore

49 CS8690 Computer Vision University of Missouri at Columbia Problem 2: Dual problem Minimize Subject to where Kühn-Tucker condition: (for x j a support vector) (  i >0 only for support vectors)

50 CS8690 Computer Vision University of Missouri at Columbia Linearly non-separable cases Find trade-off between maximum separation and misclassifications Problem 3: Minimize Subject to

51 CS8690 Computer Vision University of Missouri at Columbia Dual problem for non- separable cases Problem 4: Minimize Subject to where Kühn-Tucker condition: Support vectors: misclassified margin vectors too close OSH errors

52 CS8690 Computer Vision University of Missouri at Columbia Decision function Once w and b have been computed the classification decision for input x is given by Note that the globally optimal solution can always be obtained (convex problem) Once w and b have been computed the classification decision for input x is given by Note that the globally optimal solution can always be obtained (convex problem)

53 CS8690 Computer Vision University of Missouri at Columbia Non-linear SVMs Non-linear separation surfaces can be obtained by non-linearly mapping the data to a high dimensional space and then applying the linear SVM technique Note that data only appears through vector product Need for vector product in high-dimension can be avoided by using Mercer kernels: Non-linear separation surfaces can be obtained by non-linearly mapping the data to a high dimensional space and then applying the linear SVM technique Note that data only appears through vector product Need for vector product in high-dimension can be avoided by using Mercer kernels: (Polynomial kernel) (Radial Basis Function) (Sigmoïdal function) e.g.

54 CS8690 Computer Vision University of Missouri at Columbia Space in which decision boundary is linear - a conic in the original space has the form

55 CS8690 Computer Vision University of Missouri at Columbia SVMs for 3D object recognition -Consider images as vectors -Compute pairwise OSH using linear SVM -Support vectors are representative views of the considered object (relative to other) -Tournament like classification -Competing classes are grouped in pairs -Not selected classes are discarded -Until only one class is left -Complexity linear in number of classes -No pose estimation -Consider images as vectors -Compute pairwise OSH using linear SVM -Support vectors are representative views of the considered object (relative to other) -Tournament like classification -Competing classes are grouped in pairs -Not selected classes are discarded -Until only one class is left -Complexity linear in number of classes -No pose estimation (Pontil & Verri PAMI’98)

56 CS8690 Computer Vision University of Missouri at Columbia Vision applications Reliable, simple classifier, –use it wherever you need a classifier Commonly used for face finding Reliable, simple classifier, –use it wherever you need a classifier Commonly used for face finding Pedestrian finding –many pedestrians look like lollipops (hands at sides, torso wider than legs) most of the time –classify image regions, searching over scales –But what are the features? –Compute wavelet coefficients for pedestrian windows, average over pedestrians. If the average is different from zero, probably strongly associated with pedestrian

57 CS8690 Computer Vision University of Missouri at Columbia Figure from, “A general framework for object detection,” by C. Papageorgiou, M. Oren and T. Poggio, Proc. Int. Conf. Computer Vision, 1998, copyright 1998, IEEE

58 CS8690 Computer Vision University of Missouri at Columbia Figure from, “A general framework for object detection,” by C. Papageorgiou, M. Oren and T. Poggio, Proc. Int. Conf. Computer Vision, 1998, copyright 1998, IEEE

59 CS8690 Computer Vision University of Missouri at Columbia Figure from, “A general framework for object detection,” by C. Papageorgiou, M. Oren and T. Poggio, Proc. Int. Conf. Computer Vision, 1998, copyright 1998, IEEE


Download ppt "Template matching and object recognition. CS8690 Computer Vision University of Missouri at Columbia Recognition by finding patterns We have seen very."

Similar presentations


Ads by Google