SlideShare une entreprise Scribd logo
1  sur  48
Télécharger pour lire hors ligne
PCA-based Object Recognition

    Textbook: T&V Section 10.4



  Slide material:
     Octavia Camps, PSU
     S. Narasimhan, CMU
Template Matching


Objects can be represented by
storing sample images or “templates”


                                       Stop sign template
Hypotheses fromTemplate Matching
•Place the template at every
location on the given image.
   •Compare the pixel values in
   the template with the pixel
   values in the underlying region
   of the image.
   •If a “good” match is found,      •Possible measures are: SSD,
   announce that the object is       SAD, Cross-correlation,
                                     Normalized Cross-correlation,
   present in the image.             max difference, etc.
Limitations of Template Matching
• If the object appears scaled, rotated, or
  skewed on the image, the match will not
  be good.
Solution:
• Search for the template and possible
  transformations of the template:




             Not very efficient! (but doable …)
Using Eigenspaces
• The appearance of an object in an
  image depends on several things:
  –   Viewpoint
  –   Illumination conditions
  –   Sensor
  –   The object itself (ex: human facial expression)
• In principle, these variations can be
  handled by increasing the number of
  templates.
Eigenspaces:
     Using multiple templates
           •The number of templates can grow very fast!

           •We need:
             •An efficient way to store templates
             •An efficient way to search for matches




•Observation:      while each template is different,
there exist many similarities between the templates.
Efficient Image Storage
            Toy Example: Images with 3 pixels

Consider the following 3x1 templates:

       1       2      4      3      5      6
       2       4      8      6     10     12
       3       6      12     9     15     18


If each pixel is stored in a byte, we need 18 = 3 x 6 bytes
Efficient Image Storage
Looking closer, we can see that all the images are very
similar to each other: they are all the same image, scaled
by a factor:


    1          1       2         1      4           1
    2 =1*      2      4    =2*   2      8    =4*    2
    3          3      6          3      12          3
     3         1       5          1     6           1
     6 =3*     2      10 = 5 *    2     12 = 6 *    2
     9         3      15          3    18           3
Efficient Image Storage

      1          1      2          1       4          1
      2 =1*      2      4    =2*   2       8    =4*   2
      3          3      6          3       12         3
      3          1       5          1     6           1
      6 =3*      2      10 = 5 *    2     12 = 6 *    2
      9          3     15           3     18          3

They can be stored using only 9 bytes (50% savings!):
Store one image (3 bytes) + the multiplying constants (6 bytes)
Geometrical Interpretation:
Consider each pixel in the image as a coordinate in a
vector space. Then, each 3x1 template can be thought of
as a point in a 3D space:
                             p3




                                              p2
                  p1

But in this example, all the points happen to belong to a
line: a 1D subspace of the original 3D space.
Geometrical Interpretation:
   Consider a new coordinate system where one of the axes
   is along the direction of the line:

                                     p3




                                                         p2
                        p1
In this coordinate system, every image has only one non-zero coordinate:
we only need to store the direction of the line (a 3 bytes image) and the
non-zero coordinate for each of the images (6 bytes).
Linear Subspaces

                                convert x into v1, v2 coordinates


                                What does the v2 coordinate measure?
                                     - distance to line
                                     - use it for classification—near 0 for orange pts
                                What does the v1 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 probability density functions.
• Suppose the data points are arranged as above
   – Idea—fit a line, classifier measures distance to line
Dimensionality Reduction




• Dimensionality reduction
   – We can represent the orange points with only their v1
     coordinates
      • since v2 coordinates are all essentially 0
   – This makes it much cheaper to store and compare points
   – A bigger deal for higher dimensional problems
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: v1 is eigenvector of A with largest eigenvalue
          v2 is eigenvector of A with smallest eigenvalue
Principal Component Analysis
              (PCA)
• Given a set of templates, how do we
  know if they can be compressed like
  in the previous example?
  – The answer is to look into the
    correlation between the templates
  – The tool for doing this is called PCA
PCA Theorem
Let x1 x2 … xn be a set of n N2 x 1 vectors and let x be
their average:




Note: Each N x N image template can be represented
as a N2 x 1 vector whose elements are the template
pixel values.
PCA Theorem
Let X be the N2 x n matrix with columns x1 - x, x2 – x,… xn
–x :




  Note: subtracting the mean is equivalent to translating
  the coordinate system to the location of the mean.
PCA Theorem
Let Q = X XT be the N2 x N2 matrix:




   Notes:
     1. Q is square
     2. Q is symmetric
     3. Q is the covariance matrix [aka scatter matrix]
     4. Q can be very large (remember that N2 is the number of
         pixels in the template)
PCA Theorem
  Theorem:
       Each xj can be written as:

  where ei are the n eigenvectors of Q with non-zero
  eigenvalues.

Notes:
  1. The eigenvectors e1 e2 … en span an eigenspace
  2. e1 e2 … en are N2 x 1 orthonormal vectors (N x N images).
  3. The scalars gji are the coordinates of xj in the space.
  4.
Using PCA to Compress Data
• Expressing x in terms of e1 … en has not
  changed the size of the data

• However, if the templates are highly
  correlated many of the coordinates of x will be
  zero or closed to zero.

note: this means they lie in a
lower-dimensional linear subspace
Using PCA to Compress Data
• Sort the eigenvectors ei according to
  their eigenvalue:



 •Assuming that


 •Then
Eigenspaces:
    Efficient Image Storage
              •Use PCA to compress the data:
                 • each image is stored as a k-
                 dimensional vector
                 •Need to store k N x N
                 eigenvectors
              •k << n << N2

      a01      a02    a03    a04    a05    a06   
Eigenspaces:
Efficient Image Comparison
            •Use the same procedure to
            compress the given image to a k-
            dimensional vector.
            •Compare the compressed vectors:
              •Dot product of k-dimensional vectors
              •k << n << N2


    a01        a02    a03    a04    a05    a06   
Implementation Details:

• Need to find “first” k eigenvectors of Q:




  Q is N2 x N2 where N2 is the number of pixels in each
  image. For a 256 x 256 image, N2 = 65536 !!
Finding ev of Q
Q=XXT is very large. Instead, consider the matrix P=XTX



    •Q and P are both symmetric, but Q  PT
    •Q is N2 x N2, P is n x n
    •n is the number of training images, typically n << N
Finding ev of Q
Let e be an eigenvector of P with eigenvalue :




 Xe is an eigenvector of Q also with eigenvalue !
Singular Value Decomposition
               (SVD)
Any m x n matrix X can be written as the product of 3
matrices:



Where:
• U is m x m and its columns are orthonormal vectors
• V is n x n and its columns are orthonormal vectors
• D is m x n diagonal and its diagonal elements are called
the singular values of X, and are such that:
            1 ¸ 2 ¸ … n ¸ 0
SVD Properties



• The columns of U are the eigenvectors of XXT
• The columns of V are the eigenvectors of XTX
• The squares of the diagonal elements of D are the
eigenvalues of XXT and XTX
Algorithm EIGENSPACE_LEARN
               Assumptions:
1. Each image contains one object only.
2. Objects are imaged by a fixed camera .
3. Images are normalized in size N x N:
  •   The image frame is the minimum rectangle enclosing the object.

4. Energy of pixels values is normalized to 1:
  •   ij I(i,j)2 = 1
5. The object is completely visible and
   unoccluded in all images.
Algorithm EIGENSPACE_LEARN
              Getting the data:
For each object o to be represented, o = 1, …,O
  1. Place o on a turntable, acquire a set of n images
     by rotating the table in increments of 360o/n
  2. For each image p, p = 1, …, n:
    1. Segment o from the background
    2. Normalize the image size and energy
    3. Arrange the pixels as vectors xop
Algorithm EIGENSPACE_LEARN
           Storing the data:

1. Find the average image vector

2. Assemble the matrix X:



3. Find the first k eigenvectors of XXT: e1,…,ek
   (use XTX or SVD)

4. For each object o, each image p:
   •Compute the corresponding k-dimensional point:
Algorithm EIGENSPACE_IDENTIF
        Recognizing an object from the DB:

1. Given an image, segment the object from the background

2. Normalize the size an energy, write it as a vector i
3. Compute the corresponding k-dimensional point:




4. Find the closest gop k-dimensional point to g
Key Property of Eigenspace Representation

Given

        • 2 images   ˆ ˆ
                     x1 , x2   that are used to construct the Eigenspace

        •   ˆ                                         ˆ
            g1 is the eigenspace projection of image x1
        •   ˆ                                         ˆ
            g 2 is the eigenspace projection of image x2
Then,
                  || g 2  g1 ||  || x2  x1 ||
                     ˆ     ˆ          ˆ ˆ

        That is, distance in Eigenspace is approximately equal to the
        correlation between two images.
Example: Murase and Nayar, 1996
Database of
objects. No
background
clutter or
occlusion
Murase and Nayar, 1996

• Acquire models of object appearances
  using a turntable
Example: EigenFaces
                    These slides from S. Narasimhan, CMU




                                 =             +



• An image is a point in a high dimensional space
   – An N x M image is a point in RNM
   – We can define vectors in this space as we did in the 2D case

                                   [Thanks to Chuck Dyer, Steve Seitz, Nishino]
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 v1, v2, ..., vK

Any face:
Generating Eigenfaces – in words

1. Large set of images of human faces is taken.
2. The images are normalized to line up the
   eyes, mouths and other features.
3. The eigenvectors of the covariance matrix
   of the face image vectors are then
   extracted.
4. These eigenvectors are called eigenfaces.
Eigenfaces
                         “mean” face




Eigenfaces look somewhat like generic faces.
Eigenfaces for Face Recognition


• When properly weighted, eigenfaces can be
  summed together to create an approximate
  gray-scale rendering of a human face.

• Remarkably few eigenvector terms are needed
  to give a fair likeness of most people's faces.

• Hence eigenfaces provide a means of applying
  data compression to faces for identification
  purposes.
Eigenfaces
• PCA extracts the eigenvectors of A
   – Gives a set of vectors v1, v2, v3, ...
   – Each one of these vectors is a direction in face space
      • what do these look like?
Projecting onto the Eigenfaces

• The eigenfaces v1, ..., vK span the space of
  faces

  – A face is converted to eigenface coordinates by
Is this a face or not?
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
Cautionary Note:
      PCA has problems with occlusion
 p2        because it uses global information

      e2
                         e1

            a1   a0


                        p1




and also, more generally, with outliers



                                                PCA

Contenu connexe

Tendances

Animashree Anandkumar, Electrical Engineering and CS Dept, UC Irvine at MLcon...
Animashree Anandkumar, Electrical Engineering and CS Dept, UC Irvine at MLcon...Animashree Anandkumar, Electrical Engineering and CS Dept, UC Irvine at MLcon...
Animashree Anandkumar, Electrical Engineering and CS Dept, UC Irvine at MLcon...MLconf
 
2012 mdsp pr08 nonparametric approach
2012 mdsp pr08 nonparametric approach2012 mdsp pr08 nonparametric approach
2012 mdsp pr08 nonparametric approachnozomuhamada
 
2013 11 01(fast_grbf-nmf)_for_share
2013 11 01(fast_grbf-nmf)_for_share2013 11 01(fast_grbf-nmf)_for_share
2013 11 01(fast_grbf-nmf)_for_shareTatsuya Yokota
 
2012 mdsp pr04 monte carlo
2012 mdsp pr04 monte carlo2012 mdsp pr04 monte carlo
2012 mdsp pr04 monte carlonozomuhamada
 
Principal Components Analysis, Calculation and Visualization
Principal Components Analysis, Calculation and VisualizationPrincipal Components Analysis, Calculation and Visualization
Principal Components Analysis, Calculation and VisualizationMarjan Sterjev
 
Deep learning paper review ppt sourece -Direct clr
Deep learning paper review ppt sourece -Direct clr Deep learning paper review ppt sourece -Direct clr
Deep learning paper review ppt sourece -Direct clr taeseon ryu
 
23 industrial engineering
23 industrial engineering23 industrial engineering
23 industrial engineeringmloeb825
 
Kernel based models for geo- and environmental sciences- Alexei Pozdnoukhov –...
Kernel based models for geo- and environmental sciences- Alexei Pozdnoukhov –...Kernel based models for geo- and environmental sciences- Alexei Pozdnoukhov –...
Kernel based models for geo- and environmental sciences- Alexei Pozdnoukhov –...Beniamino Murgante
 
Animashree Anandkumar, Electrical Engineering and CS Dept, UC Irvine at MLcon...
Animashree Anandkumar, Electrical Engineering and CS Dept, UC Irvine at MLcon...Animashree Anandkumar, Electrical Engineering and CS Dept, UC Irvine at MLcon...
Animashree Anandkumar, Electrical Engineering and CS Dept, UC Irvine at MLcon...MLconf
 
Expert Lecture on GPS at UIET, CSJM, Kanpur
Expert Lecture on GPS at UIET, CSJM, KanpurExpert Lecture on GPS at UIET, CSJM, Kanpur
Expert Lecture on GPS at UIET, CSJM, KanpurSuddhasheel GHOSH, PhD
 
Aaa ped-17-Unsupervised Learning: Dimensionality reduction
Aaa ped-17-Unsupervised Learning: Dimensionality reductionAaa ped-17-Unsupervised Learning: Dimensionality reduction
Aaa ped-17-Unsupervised Learning: Dimensionality reductionAminaRepo
 
The Perceptron (DLAI D1L2 2017 UPC Deep Learning for Artificial Intelligence)
The Perceptron (DLAI D1L2 2017 UPC Deep Learning for Artificial Intelligence)The Perceptron (DLAI D1L2 2017 UPC Deep Learning for Artificial Intelligence)
The Perceptron (DLAI D1L2 2017 UPC Deep Learning for Artificial Intelligence)Universitat Politècnica de Catalunya
 
Radial Basis Function Interpolation
Radial Basis Function InterpolationRadial Basis Function Interpolation
Radial Basis Function InterpolationJesse Bettencourt
 
Discrete Models in Computer Vision
Discrete Models in Computer VisionDiscrete Models in Computer Vision
Discrete Models in Computer VisionYap Wooi Hen
 
Image Restoration UsingNonlocally Centralized Sparse Representation and histo...
Image Restoration UsingNonlocally Centralized Sparse Representation and histo...Image Restoration UsingNonlocally Centralized Sparse Representation and histo...
Image Restoration UsingNonlocally Centralized Sparse Representation and histo...IJERA Editor
 
The multilayer perceptron
The multilayer perceptronThe multilayer perceptron
The multilayer perceptronESCOM
 

Tendances (19)

Animashree Anandkumar, Electrical Engineering and CS Dept, UC Irvine at MLcon...
Animashree Anandkumar, Electrical Engineering and CS Dept, UC Irvine at MLcon...Animashree Anandkumar, Electrical Engineering and CS Dept, UC Irvine at MLcon...
Animashree Anandkumar, Electrical Engineering and CS Dept, UC Irvine at MLcon...
 
2012 mdsp pr08 nonparametric approach
2012 mdsp pr08 nonparametric approach2012 mdsp pr08 nonparametric approach
2012 mdsp pr08 nonparametric approach
 
2013 11 01(fast_grbf-nmf)_for_share
2013 11 01(fast_grbf-nmf)_for_share2013 11 01(fast_grbf-nmf)_for_share
2013 11 01(fast_grbf-nmf)_for_share
 
2012 mdsp pr04 monte carlo
2012 mdsp pr04 monte carlo2012 mdsp pr04 monte carlo
2012 mdsp pr04 monte carlo
 
Principal Components Analysis, Calculation and Visualization
Principal Components Analysis, Calculation and VisualizationPrincipal Components Analysis, Calculation and Visualization
Principal Components Analysis, Calculation and Visualization
 
Deep learning paper review ppt sourece -Direct clr
Deep learning paper review ppt sourece -Direct clr Deep learning paper review ppt sourece -Direct clr
Deep learning paper review ppt sourece -Direct clr
 
23 industrial engineering
23 industrial engineering23 industrial engineering
23 industrial engineering
 
Kernel based models for geo- and environmental sciences- Alexei Pozdnoukhov –...
Kernel based models for geo- and environmental sciences- Alexei Pozdnoukhov –...Kernel based models for geo- and environmental sciences- Alexei Pozdnoukhov –...
Kernel based models for geo- and environmental sciences- Alexei Pozdnoukhov –...
 
Animashree Anandkumar, Electrical Engineering and CS Dept, UC Irvine at MLcon...
Animashree Anandkumar, Electrical Engineering and CS Dept, UC Irvine at MLcon...Animashree Anandkumar, Electrical Engineering and CS Dept, UC Irvine at MLcon...
Animashree Anandkumar, Electrical Engineering and CS Dept, UC Irvine at MLcon...
 
Expert Lecture on GPS at UIET, CSJM, Kanpur
Expert Lecture on GPS at UIET, CSJM, KanpurExpert Lecture on GPS at UIET, CSJM, Kanpur
Expert Lecture on GPS at UIET, CSJM, Kanpur
 
Aaa ped-17-Unsupervised Learning: Dimensionality reduction
Aaa ped-17-Unsupervised Learning: Dimensionality reductionAaa ped-17-Unsupervised Learning: Dimensionality reduction
Aaa ped-17-Unsupervised Learning: Dimensionality reduction
 
The Perceptron (DLAI D1L2 2017 UPC Deep Learning for Artificial Intelligence)
The Perceptron (DLAI D1L2 2017 UPC Deep Learning for Artificial Intelligence)The Perceptron (DLAI D1L2 2017 UPC Deep Learning for Artificial Intelligence)
The Perceptron (DLAI D1L2 2017 UPC Deep Learning for Artificial Intelligence)
 
Rubik esa11
Rubik esa11Rubik esa11
Rubik esa11
 
K-means and GMM
K-means and GMMK-means and GMM
K-means and GMM
 
Radial Basis Function Interpolation
Radial Basis Function InterpolationRadial Basis Function Interpolation
Radial Basis Function Interpolation
 
Discrete Models in Computer Vision
Discrete Models in Computer VisionDiscrete Models in Computer Vision
Discrete Models in Computer Vision
 
Image Restoration UsingNonlocally Centralized Sparse Representation and histo...
Image Restoration UsingNonlocally Centralized Sparse Representation and histo...Image Restoration UsingNonlocally Centralized Sparse Representation and histo...
Image Restoration UsingNonlocally Centralized Sparse Representation and histo...
 
Gwt sdm public
Gwt sdm publicGwt sdm public
Gwt sdm public
 
The multilayer perceptron
The multilayer perceptronThe multilayer perceptron
The multilayer perceptron
 

Similaire à PCA-based Object Recognition in Images

DimensionalityReduction.pptx
DimensionalityReduction.pptxDimensionalityReduction.pptx
DimensionalityReduction.pptx36rajneekant
 
machine learning.pptx
machine learning.pptxmachine learning.pptx
machine learning.pptxAbdusSadik
 
The following ppt is about principal component analysis
The following ppt is about principal component analysisThe following ppt is about principal component analysis
The following ppt is about principal component analysisSushmit8
 
Do's and Don'ts of using t-SNE.pdf
Do's and Don'ts of using t-SNE.pdfDo's and Don'ts of using t-SNE.pdf
Do's and Don'ts of using t-SNE.pdfFrankClat
 
PR-132: SSD: Single Shot MultiBox Detector
PR-132: SSD: Single Shot MultiBox DetectorPR-132: SSD: Single Shot MultiBox Detector
PR-132: SSD: Single Shot MultiBox DetectorJinwon Lee
 
Face Recognition using PCA-Principal Component Analysis using MATLAB
Face Recognition using PCA-Principal Component Analysis using MATLABFace Recognition using PCA-Principal Component Analysis using MATLAB
Face Recognition using PCA-Principal Component Analysis using MATLABSindhi Madhuri
 
MLIP - Chapter 6 - Generation, Super-Resolution, Style transfer
MLIP - Chapter 6 - Generation, Super-Resolution, Style transferMLIP - Chapter 6 - Generation, Super-Resolution, Style transfer
MLIP - Chapter 6 - Generation, Super-Resolution, Style transferCharles Deledalle
 
Neural Networks: Principal Component Analysis (PCA)
Neural Networks: Principal Component Analysis (PCA)Neural Networks: Principal Component Analysis (PCA)
Neural Networks: Principal Component Analysis (PCA)Mostafa G. M. Mostafa
 
principle component analysis pca - machine learning - unsupervised learning
principle component analysis pca - machine learning - unsupervised learningprinciple component analysis pca - machine learning - unsupervised learning
principle component analysis pca - machine learning - unsupervised learningEmanAsem4
 
Efficient Variable Size Template Matching Using Fast Normalized Cross Correla...
Efficient Variable Size Template Matching Using Fast Normalized Cross Correla...Efficient Variable Size Template Matching Using Fast Normalized Cross Correla...
Efficient Variable Size Template Matching Using Fast Normalized Cross Correla...Gurbinder Gill
 
Nonlinear dimension reduction
Nonlinear dimension reductionNonlinear dimension reduction
Nonlinear dimension reductionYan Xu
 
Kulum alin-11 jan2014
Kulum alin-11 jan2014Kulum alin-11 jan2014
Kulum alin-11 jan2014rolly purnomo
 
5 DimensionalityReduction.pdf
5 DimensionalityReduction.pdf5 DimensionalityReduction.pdf
5 DimensionalityReduction.pdfRahul926331
 
pcappt-140121072949-phpapp01.pptx
pcappt-140121072949-phpapp01.pptxpcappt-140121072949-phpapp01.pptx
pcappt-140121072949-phpapp01.pptxABINASHPADHY6
 
Singular Value Decomposition Image Compression
Singular Value Decomposition Image CompressionSingular Value Decomposition Image Compression
Singular Value Decomposition Image CompressionAishwarya K. M.
 

Similaire à PCA-based Object Recognition in Images (20)

DimensionalityReduction.pptx
DimensionalityReduction.pptxDimensionalityReduction.pptx
DimensionalityReduction.pptx
 
Covariance.pdf
Covariance.pdfCovariance.pdf
Covariance.pdf
 
machine learning.pptx
machine learning.pptxmachine learning.pptx
machine learning.pptx
 
pca.ppt
pca.pptpca.ppt
pca.ppt
 
The following ppt is about principal component analysis
The following ppt is about principal component analysisThe following ppt is about principal component analysis
The following ppt is about principal component analysis
 
Understandig PCA and LDA
Understandig PCA and LDAUnderstandig PCA and LDA
Understandig PCA and LDA
 
Do's and Don'ts of using t-SNE.pdf
Do's and Don'ts of using t-SNE.pdfDo's and Don'ts of using t-SNE.pdf
Do's and Don'ts of using t-SNE.pdf
 
PR-132: SSD: Single Shot MultiBox Detector
PR-132: SSD: Single Shot MultiBox DetectorPR-132: SSD: Single Shot MultiBox Detector
PR-132: SSD: Single Shot MultiBox Detector
 
Face Recognition using PCA-Principal Component Analysis using MATLAB
Face Recognition using PCA-Principal Component Analysis using MATLABFace Recognition using PCA-Principal Component Analysis using MATLAB
Face Recognition using PCA-Principal Component Analysis using MATLAB
 
MLIP - Chapter 6 - Generation, Super-Resolution, Style transfer
MLIP - Chapter 6 - Generation, Super-Resolution, Style transferMLIP - Chapter 6 - Generation, Super-Resolution, Style transfer
MLIP - Chapter 6 - Generation, Super-Resolution, Style transfer
 
Neural Networks: Principal Component Analysis (PCA)
Neural Networks: Principal Component Analysis (PCA)Neural Networks: Principal Component Analysis (PCA)
Neural Networks: Principal Component Analysis (PCA)
 
PCA_csep546.pptx
PCA_csep546.pptxPCA_csep546.pptx
PCA_csep546.pptx
 
PCA_csep546.pptx
PCA_csep546.pptxPCA_csep546.pptx
PCA_csep546.pptx
 
principle component analysis pca - machine learning - unsupervised learning
principle component analysis pca - machine learning - unsupervised learningprinciple component analysis pca - machine learning - unsupervised learning
principle component analysis pca - machine learning - unsupervised learning
 
Efficient Variable Size Template Matching Using Fast Normalized Cross Correla...
Efficient Variable Size Template Matching Using Fast Normalized Cross Correla...Efficient Variable Size Template Matching Using Fast Normalized Cross Correla...
Efficient Variable Size Template Matching Using Fast Normalized Cross Correla...
 
Nonlinear dimension reduction
Nonlinear dimension reductionNonlinear dimension reduction
Nonlinear dimension reduction
 
Kulum alin-11 jan2014
Kulum alin-11 jan2014Kulum alin-11 jan2014
Kulum alin-11 jan2014
 
5 DimensionalityReduction.pdf
5 DimensionalityReduction.pdf5 DimensionalityReduction.pdf
5 DimensionalityReduction.pdf
 
pcappt-140121072949-phpapp01.pptx
pcappt-140121072949-phpapp01.pptxpcappt-140121072949-phpapp01.pptx
pcappt-140121072949-phpapp01.pptx
 
Singular Value Decomposition Image Compression
Singular Value Decomposition Image CompressionSingular Value Decomposition Image Compression
Singular Value Decomposition Image Compression
 

Plus de zukun

My lyn tutorial 2009
My lyn tutorial 2009My lyn tutorial 2009
My lyn tutorial 2009zukun
 
ETHZ CV2012: Tutorial openCV
ETHZ CV2012: Tutorial openCVETHZ CV2012: Tutorial openCV
ETHZ CV2012: Tutorial openCVzukun
 
ETHZ CV2012: Information
ETHZ CV2012: InformationETHZ CV2012: Information
ETHZ CV2012: Informationzukun
 
Siwei lyu: natural image statistics
Siwei lyu: natural image statisticsSiwei lyu: natural image statistics
Siwei lyu: natural image statisticszukun
 
Lecture9 camera calibration
Lecture9 camera calibrationLecture9 camera calibration
Lecture9 camera calibrationzukun
 
Brunelli 2008: template matching techniques in computer vision
Brunelli 2008: template matching techniques in computer visionBrunelli 2008: template matching techniques in computer vision
Brunelli 2008: template matching techniques in computer visionzukun
 
Modern features-part-4-evaluation
Modern features-part-4-evaluationModern features-part-4-evaluation
Modern features-part-4-evaluationzukun
 
Modern features-part-3-software
Modern features-part-3-softwareModern features-part-3-software
Modern features-part-3-softwarezukun
 
Modern features-part-2-descriptors
Modern features-part-2-descriptorsModern features-part-2-descriptors
Modern features-part-2-descriptorszukun
 
Modern features-part-1-detectors
Modern features-part-1-detectorsModern features-part-1-detectors
Modern features-part-1-detectorszukun
 
Modern features-part-0-intro
Modern features-part-0-introModern features-part-0-intro
Modern features-part-0-introzukun
 
Lecture 02 internet video search
Lecture 02 internet video searchLecture 02 internet video search
Lecture 02 internet video searchzukun
 
Lecture 01 internet video search
Lecture 01 internet video searchLecture 01 internet video search
Lecture 01 internet video searchzukun
 
Lecture 03 internet video search
Lecture 03 internet video searchLecture 03 internet video search
Lecture 03 internet video searchzukun
 
Icml2012 tutorial representation_learning
Icml2012 tutorial representation_learningIcml2012 tutorial representation_learning
Icml2012 tutorial representation_learningzukun
 
Advances in discrete energy minimisation for computer vision
Advances in discrete energy minimisation for computer visionAdvances in discrete energy minimisation for computer vision
Advances in discrete energy minimisation for computer visionzukun
 
Gephi tutorial: quick start
Gephi tutorial: quick startGephi tutorial: quick start
Gephi tutorial: quick startzukun
 
EM algorithm and its application in probabilistic latent semantic analysis
EM algorithm and its application in probabilistic latent semantic analysisEM algorithm and its application in probabilistic latent semantic analysis
EM algorithm and its application in probabilistic latent semantic analysiszukun
 
Object recognition with pictorial structures
Object recognition with pictorial structuresObject recognition with pictorial structures
Object recognition with pictorial structureszukun
 
Iccv2011 learning spatiotemporal graphs of human activities
Iccv2011 learning spatiotemporal graphs of human activities Iccv2011 learning spatiotemporal graphs of human activities
Iccv2011 learning spatiotemporal graphs of human activities zukun
 

Plus de zukun (20)

My lyn tutorial 2009
My lyn tutorial 2009My lyn tutorial 2009
My lyn tutorial 2009
 
ETHZ CV2012: Tutorial openCV
ETHZ CV2012: Tutorial openCVETHZ CV2012: Tutorial openCV
ETHZ CV2012: Tutorial openCV
 
ETHZ CV2012: Information
ETHZ CV2012: InformationETHZ CV2012: Information
ETHZ CV2012: Information
 
Siwei lyu: natural image statistics
Siwei lyu: natural image statisticsSiwei lyu: natural image statistics
Siwei lyu: natural image statistics
 
Lecture9 camera calibration
Lecture9 camera calibrationLecture9 camera calibration
Lecture9 camera calibration
 
Brunelli 2008: template matching techniques in computer vision
Brunelli 2008: template matching techniques in computer visionBrunelli 2008: template matching techniques in computer vision
Brunelli 2008: template matching techniques in computer vision
 
Modern features-part-4-evaluation
Modern features-part-4-evaluationModern features-part-4-evaluation
Modern features-part-4-evaluation
 
Modern features-part-3-software
Modern features-part-3-softwareModern features-part-3-software
Modern features-part-3-software
 
Modern features-part-2-descriptors
Modern features-part-2-descriptorsModern features-part-2-descriptors
Modern features-part-2-descriptors
 
Modern features-part-1-detectors
Modern features-part-1-detectorsModern features-part-1-detectors
Modern features-part-1-detectors
 
Modern features-part-0-intro
Modern features-part-0-introModern features-part-0-intro
Modern features-part-0-intro
 
Lecture 02 internet video search
Lecture 02 internet video searchLecture 02 internet video search
Lecture 02 internet video search
 
Lecture 01 internet video search
Lecture 01 internet video searchLecture 01 internet video search
Lecture 01 internet video search
 
Lecture 03 internet video search
Lecture 03 internet video searchLecture 03 internet video search
Lecture 03 internet video search
 
Icml2012 tutorial representation_learning
Icml2012 tutorial representation_learningIcml2012 tutorial representation_learning
Icml2012 tutorial representation_learning
 
Advances in discrete energy minimisation for computer vision
Advances in discrete energy minimisation for computer visionAdvances in discrete energy minimisation for computer vision
Advances in discrete energy minimisation for computer vision
 
Gephi tutorial: quick start
Gephi tutorial: quick startGephi tutorial: quick start
Gephi tutorial: quick start
 
EM algorithm and its application in probabilistic latent semantic analysis
EM algorithm and its application in probabilistic latent semantic analysisEM algorithm and its application in probabilistic latent semantic analysis
EM algorithm and its application in probabilistic latent semantic analysis
 
Object recognition with pictorial structures
Object recognition with pictorial structuresObject recognition with pictorial structures
Object recognition with pictorial structures
 
Iccv2011 learning spatiotemporal graphs of human activities
Iccv2011 learning spatiotemporal graphs of human activities Iccv2011 learning spatiotemporal graphs of human activities
Iccv2011 learning spatiotemporal graphs of human activities
 

PCA-based Object Recognition in Images

  • 1. PCA-based Object Recognition Textbook: T&V Section 10.4 Slide material: Octavia Camps, PSU S. Narasimhan, CMU
  • 2. Template Matching Objects can be represented by storing sample images or “templates” Stop sign template
  • 3. Hypotheses fromTemplate Matching •Place the template at every location on the given image. •Compare the pixel values in the template with the pixel values in the underlying region of the image. •If a “good” match is found, •Possible measures are: SSD, announce that the object is SAD, Cross-correlation, Normalized Cross-correlation, present in the image. max difference, etc.
  • 4. Limitations of Template Matching • If the object appears scaled, rotated, or skewed on the image, the match will not be good.
  • 5. Solution: • Search for the template and possible transformations of the template: Not very efficient! (but doable …)
  • 6. Using Eigenspaces • The appearance of an object in an image depends on several things: – Viewpoint – Illumination conditions – Sensor – The object itself (ex: human facial expression) • In principle, these variations can be handled by increasing the number of templates.
  • 7. Eigenspaces: Using multiple templates •The number of templates can grow very fast! •We need: •An efficient way to store templates •An efficient way to search for matches •Observation: while each template is different, there exist many similarities between the templates.
  • 8. Efficient Image Storage Toy Example: Images with 3 pixels Consider the following 3x1 templates: 1 2 4 3 5 6 2 4 8 6 10 12 3 6 12 9 15 18 If each pixel is stored in a byte, we need 18 = 3 x 6 bytes
  • 9. Efficient Image Storage Looking closer, we can see that all the images are very similar to each other: they are all the same image, scaled by a factor: 1 1 2 1 4 1 2 =1* 2 4 =2* 2 8 =4* 2 3 3 6 3 12 3 3 1 5 1 6 1 6 =3* 2 10 = 5 * 2 12 = 6 * 2 9 3 15 3 18 3
  • 10. Efficient Image Storage 1 1 2 1 4 1 2 =1* 2 4 =2* 2 8 =4* 2 3 3 6 3 12 3 3 1 5 1 6 1 6 =3* 2 10 = 5 * 2 12 = 6 * 2 9 3 15 3 18 3 They can be stored using only 9 bytes (50% savings!): Store one image (3 bytes) + the multiplying constants (6 bytes)
  • 11. Geometrical Interpretation: Consider each pixel in the image as a coordinate in a vector space. Then, each 3x1 template can be thought of as a point in a 3D space: p3 p2 p1 But in this example, all the points happen to belong to a line: a 1D subspace of the original 3D space.
  • 12. Geometrical Interpretation: Consider a new coordinate system where one of the axes is along the direction of the line: p3 p2 p1 In this coordinate system, every image has only one non-zero coordinate: we only need to store the direction of the line (a 3 bytes image) and the non-zero coordinate for each of the images (6 bytes).
  • 13. Linear Subspaces convert x into v1, v2 coordinates What does the v2 coordinate measure? - distance to line - use it for classification—near 0 for orange pts What does the v1 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 probability density functions. • Suppose the data points are arranged as above – Idea—fit a line, classifier measures distance to line
  • 14. Dimensionality Reduction • Dimensionality reduction – We can represent the orange points with only their v1 coordinates • since v2 coordinates are all essentially 0 – This makes it much cheaper to store and compare points – A bigger deal for higher dimensional problems
  • 15. 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: v1 is eigenvector of A with largest eigenvalue v2 is eigenvector of A with smallest eigenvalue
  • 16. Principal Component Analysis (PCA) • Given a set of templates, how do we know if they can be compressed like in the previous example? – The answer is to look into the correlation between the templates – The tool for doing this is called PCA
  • 17. PCA Theorem Let x1 x2 … xn be a set of n N2 x 1 vectors and let x be their average: Note: Each N x N image template can be represented as a N2 x 1 vector whose elements are the template pixel values.
  • 18. PCA Theorem Let X be the N2 x n matrix with columns x1 - x, x2 – x,… xn –x : Note: subtracting the mean is equivalent to translating the coordinate system to the location of the mean.
  • 19. PCA Theorem Let Q = X XT be the N2 x N2 matrix: Notes: 1. Q is square 2. Q is symmetric 3. Q is the covariance matrix [aka scatter matrix] 4. Q can be very large (remember that N2 is the number of pixels in the template)
  • 20. PCA Theorem Theorem: Each xj can be written as: where ei are the n eigenvectors of Q with non-zero eigenvalues. Notes: 1. The eigenvectors e1 e2 … en span an eigenspace 2. e1 e2 … en are N2 x 1 orthonormal vectors (N x N images). 3. The scalars gji are the coordinates of xj in the space. 4.
  • 21. Using PCA to Compress Data • Expressing x in terms of e1 … en has not changed the size of the data • However, if the templates are highly correlated many of the coordinates of x will be zero or closed to zero. note: this means they lie in a lower-dimensional linear subspace
  • 22. Using PCA to Compress Data • Sort the eigenvectors ei according to their eigenvalue: •Assuming that •Then
  • 23. Eigenspaces: Efficient Image Storage •Use PCA to compress the data: • each image is stored as a k- dimensional vector •Need to store k N x N eigenvectors •k << n << N2   a01  a02  a03  a04  a05  a06 
  • 24. Eigenspaces: Efficient Image Comparison •Use the same procedure to compress the given image to a k- dimensional vector. •Compare the compressed vectors: •Dot product of k-dimensional vectors •k << n << N2   a01  a02  a03  a04  a05  a06 
  • 25. Implementation Details: • Need to find “first” k eigenvectors of Q: Q is N2 x N2 where N2 is the number of pixels in each image. For a 256 x 256 image, N2 = 65536 !!
  • 26. Finding ev of Q Q=XXT is very large. Instead, consider the matrix P=XTX •Q and P are both symmetric, but Q  PT •Q is N2 x N2, P is n x n •n is the number of training images, typically n << N
  • 27. Finding ev of Q Let e be an eigenvector of P with eigenvalue : Xe is an eigenvector of Q also with eigenvalue !
  • 28. Singular Value Decomposition (SVD) Any m x n matrix X can be written as the product of 3 matrices: Where: • U is m x m and its columns are orthonormal vectors • V is n x n and its columns are orthonormal vectors • D is m x n diagonal and its diagonal elements are called the singular values of X, and are such that: 1 ¸ 2 ¸ … n ¸ 0
  • 29. SVD Properties • The columns of U are the eigenvectors of XXT • The columns of V are the eigenvectors of XTX • The squares of the diagonal elements of D are the eigenvalues of XXT and XTX
  • 30. Algorithm EIGENSPACE_LEARN Assumptions: 1. Each image contains one object only. 2. Objects are imaged by a fixed camera . 3. Images are normalized in size N x N: • The image frame is the minimum rectangle enclosing the object. 4. Energy of pixels values is normalized to 1: • ij I(i,j)2 = 1 5. The object is completely visible and unoccluded in all images.
  • 31. Algorithm EIGENSPACE_LEARN Getting the data: For each object o to be represented, o = 1, …,O 1. Place o on a turntable, acquire a set of n images by rotating the table in increments of 360o/n 2. For each image p, p = 1, …, n: 1. Segment o from the background 2. Normalize the image size and energy 3. Arrange the pixels as vectors xop
  • 32. Algorithm EIGENSPACE_LEARN Storing the data: 1. Find the average image vector 2. Assemble the matrix X: 3. Find the first k eigenvectors of XXT: e1,…,ek (use XTX or SVD) 4. For each object o, each image p: •Compute the corresponding k-dimensional point:
  • 33. Algorithm EIGENSPACE_IDENTIF Recognizing an object from the DB: 1. Given an image, segment the object from the background 2. Normalize the size an energy, write it as a vector i 3. Compute the corresponding k-dimensional point: 4. Find the closest gop k-dimensional point to g
  • 34. Key Property of Eigenspace Representation Given • 2 images ˆ ˆ x1 , x2 that are used to construct the Eigenspace • ˆ ˆ g1 is the eigenspace projection of image x1 • ˆ ˆ g 2 is the eigenspace projection of image x2 Then, || g 2  g1 ||  || x2  x1 || ˆ ˆ ˆ ˆ That is, distance in Eigenspace is approximately equal to the correlation between two images.
  • 35. Example: Murase and Nayar, 1996 Database of objects. No background clutter or occlusion
  • 36. Murase and Nayar, 1996 • Acquire models of object appearances using a turntable
  • 37.
  • 38.
  • 39. Example: EigenFaces These slides from S. Narasimhan, CMU = + • An image is a point in a high dimensional space – An N x M image is a point in RNM – We can define vectors in this space as we did in the 2D case [Thanks to Chuck Dyer, Steve Seitz, Nishino]
  • 40. 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 v1, v2, ..., vK Any face:
  • 41. Generating Eigenfaces – in words 1. Large set of images of human faces is taken. 2. The images are normalized to line up the eyes, mouths and other features. 3. The eigenvectors of the covariance matrix of the face image vectors are then extracted. 4. These eigenvectors are called eigenfaces.
  • 42. Eigenfaces “mean” face Eigenfaces look somewhat like generic faces.
  • 43. Eigenfaces for Face Recognition • When properly weighted, eigenfaces can be summed together to create an approximate gray-scale rendering of a human face. • Remarkably few eigenvector terms are needed to give a fair likeness of most people's faces. • Hence eigenfaces provide a means of applying data compression to faces for identification purposes.
  • 44. Eigenfaces • PCA extracts the eigenvectors of A – Gives a set of vectors v1, v2, v3, ... – Each one of these vectors is a direction in face space • what do these look like?
  • 45. Projecting onto the Eigenfaces • The eigenfaces v1, ..., vK span the space of faces – A face is converted to eigenface coordinates by
  • 46. Is this a face or not?
  • 47. 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
  • 48. Cautionary Note: PCA has problems with occlusion p2 because it uses global information e2 e1 a1 a0 p1 and also, more generally, with outliers PCA