SlideShare a Scribd company logo
1 of 27
Features extraction and representation / Image processing
Farah Al-Tufaili
The reader is probably familiar with the common saying that goes
something along the lines of ‘Why use a hundred words when ten
will do?’ This idea of expressing information in it’s most succinct
and compact form embodies very accurately the central idea behind
Principal Component Analysis (PCA) a very important and
powerful statistical technique.
Purpose: to reduce dimensionality of a vector image while maintaining
information as much as possible.
PCA- by Farah Al-Tufaili 2
Some of the more significant aspects of digital imaging in which it
has found useful application include the classification of
photographic film, remote sensing and data compression, and
automated facial recognition and facial synthesis, an Application of
PCA.
It is also commonly used as a low-level image processing tool for
certain tasks, such as determination of the orientation of basic
shapes.
PCA- by Farah Al-Tufaili 3
PCA steps: transform an 𝑁×𝑑 matrix 𝑋 into an 𝑁×𝑚 matrix
𝑌:
Centralized the data (subtract the mean).
Calculate the 𝑑×𝑑 covariance matrix: C=
1
𝑁−1
𝑋 𝑇 𝑋
 𝐶𝑖,𝑗=
1
𝑁−1 𝑞=1
𝑁
𝑋 𝑞,𝑖. 𝑋 𝑞,𝑗
 𝐶𝑖,𝑖 (diagonal) is the variance of variable i.
 𝐶𝑖,𝑗 (off-diagonal) is the covariance between variables i and j.
Calculate the eigenvectors of the covariance matrix (orthonormal).
PCA- by Farah Al-Tufaili 4
Let
Covariance matrix


K
k
T
xx
T
kk
T
xxx
K
E
1
1
}))({( mmxxmxmxC
T
nxxx ]...[ 21x
PCA- by Farah Al-Tufaili 5
A 2-D facial image can be represented as 1-D vector by concatenating each row (or column) into a
long thin vector. Let’s suppose we have M vectors of size N (= rows of image × columns of image)
representing a set of sampled images. pj’s represent the pixel values.
xi = [p1 ...pN]T,i = 1,...,M (1)
The images are mean centered by subtracting the mean image from each image vector. Let m
represent the mean image.
(2)
And let wi be defined as mean centered image
wi = xi − m (3)
Our goal is to find a set of ei’s which have the largest possible projection onto each of the wi’s. We
wish to find a set of M orthonormal vectors ei for which the quantity
(4)
is maximized with the orthonormality constraint
PCA- by Farah Al-Tufaili 6
 This example illustrates the primary and essential requirement for PCA to be
useful: there must be some degree of correlation between the data vectors. In
fact, the more strongly correlated the original data, the more effective PCA is
likely to be.
 To provide some concrete but simple data to work with, consider that we have
just M=2 measurements on the height h and the weight w of a sample group of
N=12 people as given in Table 9.2. Figure 9.7 plots the mean-subtracted data in
the 2-D feature space (w, h) and it is evident that the data shows considerable
variance over both
PCA- by Farah Al-Tufaili 8
variables and that they are correlated. The sample covariance matrix for these
two variables is calculated as:
Where x=(h w)T and x=(h w)T is the simple mean.
PCA- by Farah Al-Tufaili 9
Weight (X) Height (Y) X-mean Y-mean
65 170 -4.416666667 -3.25
75 176 5.583333333 2.75
53 154 -16.41666667 -19.25
54 167 -15.41666667 -6.25
61 171 -8.416666667 -2.25
88 184 18.58333333 10.75
70 182 0.583333333 8.75
78 190 8.583333333 16.75
52 166 -17.41666667 -7.25
95 168 25.58333333 -5.25
70 176 0.583333333 2.75
72 175 2.583333333 1.75
Mean: 69.41666667 173.25 Variance: 182.9924 90.5682
Applying the equation: 

K
k
T
xx
T
kk
T
xxx
K
E
1
1
}))({( mmxxmxmxC
PCA- by Farah Al-Tufaili 10
clc
x=[65 75 53 54 61 88 70 78 52 95 70 72]
y=[170 176 154 167 171 184 182 190 166 168 176 175]
x_mean=mean(x) , y_mean=mean(y)
x1=x-x_mean; y1=y-y_mean;
var_x=sum(x1.^2)/(length(x)-1)
var_y=sum(y1.^2)/(length(y)-1)
cv=(x1).*(y1);
cov=sum(cv)/(length(x)-1)
Output:
x_mean =
69.4167
y_mean =
173.2500
var_x =
182.9924
var_y =
90.5682
cov =
73.4318
PCA- by Farah Al-Tufaili 11
• The basic aim of PCA is to effect a rotation of the coordinate system and
thereby express the data in terms of a new set of variables or equivalently
axes which are uncorrelated.
• How are these found? The first principal axis is chosen to satisfy the following
criterion:
• The axis passing through the data points which maximizes the sum of the
squared lengths of the perpendicular projection of the data points onto that
axis is the principal axis.
PCA- by Farah Al-Tufaili 12
Figure 9.7 Distribution of weight and height values within a 2-D feature space. The mean
value of each variable has been subtracted from the data
PCA- by Farah Al-Tufaili 13
Thus, the principal axis is oriented so as to maximize the overall variance of the data with respect to it
(a variance-maximizing transform). We note in passing that an alternative but entirely equivalent
criterion for a principal axis is that it minimizes the sum of the squared errors (differences) between
the actual data points and their perpendicular projections onto the said straight line. This concept is
illustrated in Figure 9.8.
Let us suppose that the first principal axis has been found. To calculate the second principal axis we
proceed as follows:
 Calculate the projections of the data points onto the first principal axis.
 Subtract these projected values from the original data. The modified set of data points is termed the
residual data.
 The second principal axis is then calculated to satisfy an identical criterion to the first (i.e. the
variance of the residual data is maximized along this axis).
PCA- by Farah Al-Tufaili 14
Note also that this is distinct from fitting a straight line by regression. In regression, x is an
independent variable and y the dependent variable and we seek to minimize the sum of the
squared errors between the actual y values and their predicted values.
PCA- by Farah Al-Tufaili 15
PCA- by Farah Al-Tufaili 16
In fact, this alignment is precisely the mechanism that decorrelatcs the data. Furthermore, as the
eigenvalues appear along the main diagonal of Cy ,λ i is the variance of component yi along
eigenvector ei . The two eigenvectors are perpendicular. The y-axes sometimes are called the
eigen axes for obvious reasons.
PCA- by Farah Al-Tufaili 17
 let the covariance matrix is :
7 3
3 −1
 First Step: compute eigenvalues. To do this, we find the values of which satisfy
the characteristic equation of the matrix A, namely those values of for which
det(A − I) = 0,
1. λ I= λ
1 0
0 1
=
λ 0
0 λ
2. A- λI=
7 3
3 −1
-
λ 0
0 λ
=
7 − λ 3
3 −1 − λ
3. det
7 3
3 −1
= (7- λ)(-1- λ)-(3)(3)= -7-7λ+λ+ λ2-9= λ2-6 λ-16
(λ-8)(λ+2)=0 λ1=8 λ2=-2
EigenValues
Let this
equation equal
to zero and
solve it
PCA- by Farah Al-Tufaili 18
 Second step: find corresponding eigenvectors.
1. For each eigenvalue λ, we have (A − λ I)V = 0, where x is the eigenvector
associated with eigenvalue λ.
2. Find x by Gaussian elimination. That is, convert the augmented matrix
(A − λ I ⋮ 0)
to row echelon form, and solve the resulting linear system by back
substitution.
We find the eigenvectors associated with each of the eigenvalues
PCA- by Farah Al-Tufaili 19
−1𝑣1+ 3𝑣2 = 0 ………..(1
3𝑣1- 9𝑣2 = 0 ………..(2
2𝑣1- 6𝑣2 = 0 ………..(3
Lets 𝑠 =
(2)2+(−6)2=6.3246
v1 = 2/6.3246= 0.3162
v2 = -6/6.3246= -0.9487
PCA- by Farah Al-Tufaili 20
When λ1=8
A- λI=
7 − 8 3
3 −1 − 8
=
−1 3
3 −9
(A − λ I)V = 0
−1 3
3 −9
⋮
𝑣1
𝑣2
=0
−𝟏 × 𝐯 𝟏 + 𝟑 × 𝐯 𝟐 = 𝟎
𝟑 × 𝐯 𝟏 + −𝟗 × 𝐯 𝟐 = 𝟎
PCA- by Farah Al-Tufaili 21
9𝑣1+ 3𝑣2 = 0 ………..(1
3𝑣1+1𝑣2 = 0 ………..(2
6𝑣1+2𝑣2 = 0 ………..(3
Lets 𝑠 =
(2)2+(6)2=6.3246
v1 = -6/6.3246= -0.9487
v2 = -2/6.3246= -0.3162
When λ1=-2
A- λI=
7 + 2 3
3 −1 + 2
=
9 3
3 1
(A − λ I)V = 0
9 3
3 1
⋮
𝑣1
𝑣2
=0
𝟗 × 𝐯 𝟏 + 𝟑 × 𝐯 𝟐 = 𝟎
𝟑 × 𝐯 𝟏 + 𝟏 × 𝐯 𝟐 = 𝟎
check our solution in Matlab:
>> x=[7 3;3 -1]
x =
7 3
3 -1
>>[a b]=eig(x)
a =
0.3162 -0.9487
-0.9487 -0.3162
b =
-2 0
0 8
PCA- by Farah Al-Tufaili 22
EigenValues
EigenVictor
 There is a subtle difference between the two alternative derivations we have
offered. In the first case we considered our variables to define the feature space
and derived a set of principal axes. The dimensionality of our feature space
was determined by the number of variables and the diagonalizing matrix of
eigenvectors R to produce a new set of axes in that 2-D space. Our second
formulation leads to essentially the same procedure (i.e. to diagonalize the
covariance matrix), but it nonetheless admits an alternative viewpoint. In this
instance, we view the observations on each of the variables to define our
(higher dimensional) feature vectors. The role of the diagonalizing matrix of
eigenvectors R here is thus to multiply and transform these higher dimensional
vectors to produce a new orthogonal (principal) set. Thus, the dimensionality
of the space here is determined by the number of observations made on each of
the variables.
PCA- by Farah Al-Tufaili 23
W=[65 75 53 54 61 88 70 78 52 95 70 72]' %1. Form data vector on weight
H=[170 176 154 167 171 184 182 190 166 168 176 175]' %Form data vector on height
XM=[mean(W).*ones(length(W),1) mean(H).*ones(length(H),1)] %matrix with mean values replicated
X=[W H]-XM %Form mean-subtracted data matrix
Cx=cov(X) %calculate covariance on data
[R,LAMBDA,Q]=svd(Cx) %Get eigenvalues LAMBDA and eigenvectors R
V=X*R %Calculate principal components
subplot(1,2,1), plot(X(:,1),X(:,2),'ko'); grid on; %2. display data on original axes
subplot(1,2,2), plot(V(:,1),V(:,2),'ro'); grid on; %display PCs as data in rotated space
XR=XM+V*R' %3. Reconstruct data in terms of PCs
XR-[W H] %Confirm reconstruction (diff = 0)
V'*V./(length(W)-1) %4. Confirm covariance terms
%MATLAB FUNCTIONS cov, mean, svd,
PCA- by Farah Al-Tufaili 24
The weight–height data referred to the original axes x1 and x2 and to the principal axes v1 and v2
PCA- by Farah Al-Tufaili 25
• It is self-evident that the basic
placement, size and shape of human
facial features are similar. Therefore,
we can expect that an ensemble of
suitably scaled and registered images
of the human face will exhibit fairly
strong correlation. Each image
consisted of 21 054 grey-scale pixel
values.
Figure 9.13 A sample of human faces scaled and
registered such that each can be described by the
same number of pixels (21 054).
PCA- by Farah Al-Tufaili 26
Figure 9.15 The first six facial principal components from a sample of 290 faces.
The first principal is the average face. Note the strong male appearance coded by
principal component no. 3
PCA- by Farah Al-Tufaili 27
Any Questions?
PCA- by Farah Al-Tufaili 28

More Related Content

What's hot

Maximum Likelihood Estimation
Maximum Likelihood EstimationMaximum Likelihood Estimation
Maximum Likelihood Estimationguestfee8698
 
Lect5 principal component analysis
Lect5 principal component analysisLect5 principal component analysis
Lect5 principal component analysishktripathy
 
Introduction to Principle Component Analysis
Introduction to Principle Component AnalysisIntroduction to Principle Component Analysis
Introduction to Principle Component AnalysisSunjeet Jena
 
Introduction to principal component analysis (pca)
Introduction to principal component analysis (pca)Introduction to principal component analysis (pca)
Introduction to principal component analysis (pca)Mohammed Musah
 
Activation functions and Training Algorithms for Deep Neural network
Activation functions and Training Algorithms for Deep Neural networkActivation functions and Training Algorithms for Deep Neural network
Activation functions and Training Algorithms for Deep Neural networkGayatri Khanvilkar
 
Pca(principal components analysis)
Pca(principal components analysis)Pca(principal components analysis)
Pca(principal components analysis)kalung0313
 
Introduction to Linear Discriminant Analysis
Introduction to Linear Discriminant AnalysisIntroduction to Linear Discriminant Analysis
Introduction to Linear Discriminant AnalysisJaclyn Kokx
 
Feature selection
Feature selectionFeature selection
Feature selectionDong Guo
 
Implement principal component analysis (PCA) in python from scratch
Implement principal component analysis (PCA) in python from scratchImplement principal component analysis (PCA) in python from scratch
Implement principal component analysis (PCA) in python from scratchEshanAgarwal4
 
Methods of Optimization in Machine Learning
Methods of Optimization in Machine LearningMethods of Optimization in Machine Learning
Methods of Optimization in Machine LearningKnoldus Inc.
 
Maximum likelihood estimation
Maximum likelihood estimationMaximum likelihood estimation
Maximum likelihood estimationzihad164
 
Steps for Principal Component Analysis (pca) using ERDAS software
Steps for Principal Component Analysis (pca) using ERDAS softwareSteps for Principal Component Analysis (pca) using ERDAS software
Steps for Principal Component Analysis (pca) using ERDAS softwareSwetha A
 
Decision trees in Machine Learning
Decision trees in Machine Learning Decision trees in Machine Learning
Decision trees in Machine Learning Mohammad Junaid Khan
 
Principal Component Analysis and Clustering
Principal Component Analysis and ClusteringPrincipal Component Analysis and Clustering
Principal Component Analysis and ClusteringUsha Vijay
 
22 Machine Learning Feature Selection
22 Machine Learning Feature Selection22 Machine Learning Feature Selection
22 Machine Learning Feature SelectionAndres Mendez-Vazquez
 
Dimensionality Reduction
Dimensionality ReductionDimensionality Reduction
Dimensionality Reductionmrizwan969
 

What's hot (20)

Maximum Likelihood Estimation
Maximum Likelihood EstimationMaximum Likelihood Estimation
Maximum Likelihood Estimation
 
Principal component analysis
Principal component analysisPrincipal component analysis
Principal component analysis
 
Lect5 principal component analysis
Lect5 principal component analysisLect5 principal component analysis
Lect5 principal component analysis
 
pca.ppt
pca.pptpca.ppt
pca.ppt
 
Introduction to Principle Component Analysis
Introduction to Principle Component AnalysisIntroduction to Principle Component Analysis
Introduction to Principle Component Analysis
 
Introduction to principal component analysis (pca)
Introduction to principal component analysis (pca)Introduction to principal component analysis (pca)
Introduction to principal component analysis (pca)
 
Activation functions and Training Algorithms for Deep Neural network
Activation functions and Training Algorithms for Deep Neural networkActivation functions and Training Algorithms for Deep Neural network
Activation functions and Training Algorithms for Deep Neural network
 
Pca(principal components analysis)
Pca(principal components analysis)Pca(principal components analysis)
Pca(principal components analysis)
 
Introduction to Linear Discriminant Analysis
Introduction to Linear Discriminant AnalysisIntroduction to Linear Discriminant Analysis
Introduction to Linear Discriminant Analysis
 
Pca
PcaPca
Pca
 
Feature selection
Feature selectionFeature selection
Feature selection
 
Implement principal component analysis (PCA) in python from scratch
Implement principal component analysis (PCA) in python from scratchImplement principal component analysis (PCA) in python from scratch
Implement principal component analysis (PCA) in python from scratch
 
Methods of Optimization in Machine Learning
Methods of Optimization in Machine LearningMethods of Optimization in Machine Learning
Methods of Optimization in Machine Learning
 
Maximum likelihood estimation
Maximum likelihood estimationMaximum likelihood estimation
Maximum likelihood estimation
 
Steps for Principal Component Analysis (pca) using ERDAS software
Steps for Principal Component Analysis (pca) using ERDAS softwareSteps for Principal Component Analysis (pca) using ERDAS software
Steps for Principal Component Analysis (pca) using ERDAS software
 
Decision trees in Machine Learning
Decision trees in Machine Learning Decision trees in Machine Learning
Decision trees in Machine Learning
 
Principal Component Analysis and Clustering
Principal Component Analysis and ClusteringPrincipal Component Analysis and Clustering
Principal Component Analysis and Clustering
 
22 Machine Learning Feature Selection
22 Machine Learning Feature Selection22 Machine Learning Feature Selection
22 Machine Learning Feature Selection
 
A Gentle Introduction to the EM Algorithm
A Gentle Introduction to the EM AlgorithmA Gentle Introduction to the EM Algorithm
A Gentle Introduction to the EM Algorithm
 
Dimensionality Reduction
Dimensionality ReductionDimensionality Reduction
Dimensionality Reduction
 

Similar to Principal component analysis

Linear regression [Theory and Application (In physics point of view) using py...
Linear regression [Theory and Application (In physics point of view) using py...Linear regression [Theory and Application (In physics point of view) using py...
Linear regression [Theory and Application (In physics point of view) using py...ANIRBANMAJUMDAR18
 
Machine learning (11)
Machine learning (11)Machine learning (11)
Machine learning (11)NYversity
 
Conference_paper.pdf
Conference_paper.pdfConference_paper.pdf
Conference_paper.pdfNarenRajVivek
 
Principal Component Analysis
Principal Component AnalysisPrincipal Component Analysis
Principal Component AnalysisMason Ziemer
 
SupportVectorRegression
SupportVectorRegressionSupportVectorRegression
SupportVectorRegressionDaniel K
 
Exploring Support Vector Regression - Signals and Systems Project
Exploring Support Vector Regression - Signals and Systems ProjectExploring Support Vector Regression - Signals and Systems Project
Exploring Support Vector Regression - Signals and Systems ProjectSurya Chandra
 
Cs229 notes10
Cs229 notes10Cs229 notes10
Cs229 notes10VuTran231
 
directed-research-report
directed-research-reportdirected-research-report
directed-research-reportRyen Krusinga
 
Workload-aware materialization for efficient variable elimination on Bayesian...
Workload-aware materialization for efficient variable elimination on Bayesian...Workload-aware materialization for efficient variable elimination on Bayesian...
Workload-aware materialization for efficient variable elimination on Bayesian...Cigdem Aslay
 
Human Face Detection Based on Combination of Logistic Regression, Distance of...
Human Face Detection Based on Combination of Logistic Regression, Distance of...Human Face Detection Based on Combination of Logistic Regression, Distance of...
Human Face Detection Based on Combination of Logistic Regression, Distance of...IJCSIS Research Publications
 
On image intensities, eigenfaces and LDA
On image intensities, eigenfaces and LDAOn image intensities, eigenfaces and LDA
On image intensities, eigenfaces and LDARaghu Palakodety
 
COMPARISON OF WAVELET NETWORK AND LOGISTIC REGRESSION IN PREDICTING ENTERPRIS...
COMPARISON OF WAVELET NETWORK AND LOGISTIC REGRESSION IN PREDICTING ENTERPRIS...COMPARISON OF WAVELET NETWORK AND LOGISTIC REGRESSION IN PREDICTING ENTERPRIS...
COMPARISON OF WAVELET NETWORK AND LOGISTIC REGRESSION IN PREDICTING ENTERPRIS...ijcsit
 
DETECTION OF MOVING OBJECT
DETECTION OF MOVING OBJECTDETECTION OF MOVING OBJECT
DETECTION OF MOVING OBJECTAM Publications
 
Wiener Filter Hardware Realization
Wiener Filter Hardware RealizationWiener Filter Hardware Realization
Wiener Filter Hardware RealizationSayan Chaudhuri
 

Similar to Principal component analysis (20)

Linear regression [Theory and Application (In physics point of view) using py...
Linear regression [Theory and Application (In physics point of view) using py...Linear regression [Theory and Application (In physics point of view) using py...
Linear regression [Theory and Application (In physics point of view) using py...
 
Machine learning (11)
Machine learning (11)Machine learning (11)
Machine learning (11)
 
Conference_paper.pdf
Conference_paper.pdfConference_paper.pdf
Conference_paper.pdf
 
Principal Component Analysis
Principal Component AnalysisPrincipal Component Analysis
Principal Component Analysis
 
Regression
RegressionRegression
Regression
 
SupportVectorRegression
SupportVectorRegressionSupportVectorRegression
SupportVectorRegression
 
Exploring Support Vector Regression - Signals and Systems Project
Exploring Support Vector Regression - Signals and Systems ProjectExploring Support Vector Regression - Signals and Systems Project
Exploring Support Vector Regression - Signals and Systems Project
 
Cs229 notes10
Cs229 notes10Cs229 notes10
Cs229 notes10
 
directed-research-report
directed-research-reportdirected-research-report
directed-research-report
 
working with python
working with pythonworking with python
working with python
 
recko_paper
recko_paperrecko_paper
recko_paper
 
MSE.pptx
MSE.pptxMSE.pptx
MSE.pptx
 
Workload-aware materialization for efficient variable elimination on Bayesian...
Workload-aware materialization for efficient variable elimination on Bayesian...Workload-aware materialization for efficient variable elimination on Bayesian...
Workload-aware materialization for efficient variable elimination on Bayesian...
 
Human Face Detection Based on Combination of Logistic Regression, Distance of...
Human Face Detection Based on Combination of Logistic Regression, Distance of...Human Face Detection Based on Combination of Logistic Regression, Distance of...
Human Face Detection Based on Combination of Logistic Regression, Distance of...
 
On image intensities, eigenfaces and LDA
On image intensities, eigenfaces and LDAOn image intensities, eigenfaces and LDA
On image intensities, eigenfaces and LDA
 
overviewPCA
overviewPCAoverviewPCA
overviewPCA
 
COMPARISON OF WAVELET NETWORK AND LOGISTIC REGRESSION IN PREDICTING ENTERPRIS...
COMPARISON OF WAVELET NETWORK AND LOGISTIC REGRESSION IN PREDICTING ENTERPRIS...COMPARISON OF WAVELET NETWORK AND LOGISTIC REGRESSION IN PREDICTING ENTERPRIS...
COMPARISON OF WAVELET NETWORK AND LOGISTIC REGRESSION IN PREDICTING ENTERPRIS...
 
DETECTION OF MOVING OBJECT
DETECTION OF MOVING OBJECTDETECTION OF MOVING OBJECT
DETECTION OF MOVING OBJECT
 
Wiener Filter Hardware Realization
Wiener Filter Hardware RealizationWiener Filter Hardware Realization
Wiener Filter Hardware Realization
 
Chapter26
Chapter26Chapter26
Chapter26
 

More from Farah M. Altufaili

More from Farah M. Altufaili (10)

A Correlative Information-Theoretic Measure for Image Similarity
A Correlative Information-Theoretic Measure for Image SimilarityA Correlative Information-Theoretic Measure for Image Similarity
A Correlative Information-Theoretic Measure for Image Similarity
 
Fp growth
Fp growthFp growth
Fp growth
 
Stereo vision
Stereo visionStereo vision
Stereo vision
 
Writing a good cv
Writing a good cvWriting a good cv
Writing a good cv
 
Virtual Private Network VPN
Virtual Private Network VPNVirtual Private Network VPN
Virtual Private Network VPN
 
Fuzzy image processing- fuzzy C-mean clustering
Fuzzy image processing- fuzzy C-mean clusteringFuzzy image processing- fuzzy C-mean clustering
Fuzzy image processing- fuzzy C-mean clustering
 
Tiny encryption algorithm
Tiny encryption algorithmTiny encryption algorithm
Tiny encryption algorithm
 
Polygon mesh
Polygon  meshPolygon  mesh
Polygon mesh
 
Nanotechnology and its impact on modern computer
Nanotechnology and its impact on modern computerNanotechnology and its impact on modern computer
Nanotechnology and its impact on modern computer
 
Adversarial search
Adversarial search Adversarial search
Adversarial search
 

Recently uploaded

Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bSérgio Sacani
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Lokesh Kothari
 
GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)Areesha Ahmad
 
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...anilsa9823
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPirithiRaju
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksSérgio Sacani
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRDelhi Call girls
 
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencyHire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencySheetal Arora
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPirithiRaju
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsAArockiyaNisha
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPirithiRaju
 
Zoology 4th semester series (krishna).pdf
Zoology 4th semester series (krishna).pdfZoology 4th semester series (krishna).pdf
Zoology 4th semester series (krishna).pdfSumit Kumar yadav
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...Sérgio Sacani
 
GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)Areesha Ahmad
 
fundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomologyfundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomologyDrAnita Sharma
 
Botany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsBotany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsSumit Kumar yadav
 
Green chemistry and Sustainable development.pptx
Green chemistry  and Sustainable development.pptxGreen chemistry  and Sustainable development.pptx
Green chemistry and Sustainable development.pptxRajatChauhan518211
 
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSpermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSarthak Sekhar Mondal
 
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 60009654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000Sapana Sha
 

Recently uploaded (20)

The Philosophy of Science
The Philosophy of ScienceThe Philosophy of Science
The Philosophy of Science
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
 
GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)
 
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdf
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disks
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
 
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencyHire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based Nanomaterials
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
 
Zoology 4th semester series (krishna).pdf
Zoology 4th semester series (krishna).pdfZoology 4th semester series (krishna).pdf
Zoology 4th semester series (krishna).pdf
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
 
GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)
 
fundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomologyfundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomology
 
Botany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsBotany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questions
 
Green chemistry and Sustainable development.pptx
Green chemistry  and Sustainable development.pptxGreen chemistry  and Sustainable development.pptx
Green chemistry and Sustainable development.pptx
 
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSpermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
 
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 60009654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
 

Principal component analysis

  • 1. Features extraction and representation / Image processing Farah Al-Tufaili
  • 2. The reader is probably familiar with the common saying that goes something along the lines of ‘Why use a hundred words when ten will do?’ This idea of expressing information in it’s most succinct and compact form embodies very accurately the central idea behind Principal Component Analysis (PCA) a very important and powerful statistical technique. Purpose: to reduce dimensionality of a vector image while maintaining information as much as possible. PCA- by Farah Al-Tufaili 2
  • 3. Some of the more significant aspects of digital imaging in which it has found useful application include the classification of photographic film, remote sensing and data compression, and automated facial recognition and facial synthesis, an Application of PCA. It is also commonly used as a low-level image processing tool for certain tasks, such as determination of the orientation of basic shapes. PCA- by Farah Al-Tufaili 3
  • 4. PCA steps: transform an 𝑁×𝑑 matrix 𝑋 into an 𝑁×𝑚 matrix 𝑌: Centralized the data (subtract the mean). Calculate the 𝑑×𝑑 covariance matrix: C= 1 𝑁−1 𝑋 𝑇 𝑋  𝐶𝑖,𝑗= 1 𝑁−1 𝑞=1 𝑁 𝑋 𝑞,𝑖. 𝑋 𝑞,𝑗  𝐶𝑖,𝑖 (diagonal) is the variance of variable i.  𝐶𝑖,𝑗 (off-diagonal) is the covariance between variables i and j. Calculate the eigenvectors of the covariance matrix (orthonormal). PCA- by Farah Al-Tufaili 4
  • 6. A 2-D facial image can be represented as 1-D vector by concatenating each row (or column) into a long thin vector. Let’s suppose we have M vectors of size N (= rows of image × columns of image) representing a set of sampled images. pj’s represent the pixel values. xi = [p1 ...pN]T,i = 1,...,M (1) The images are mean centered by subtracting the mean image from each image vector. Let m represent the mean image. (2) And let wi be defined as mean centered image wi = xi − m (3) Our goal is to find a set of ei’s which have the largest possible projection onto each of the wi’s. We wish to find a set of M orthonormal vectors ei for which the quantity (4) is maximized with the orthonormality constraint PCA- by Farah Al-Tufaili 6
  • 7.  This example illustrates the primary and essential requirement for PCA to be useful: there must be some degree of correlation between the data vectors. In fact, the more strongly correlated the original data, the more effective PCA is likely to be.  To provide some concrete but simple data to work with, consider that we have just M=2 measurements on the height h and the weight w of a sample group of N=12 people as given in Table 9.2. Figure 9.7 plots the mean-subtracted data in the 2-D feature space (w, h) and it is evident that the data shows considerable variance over both PCA- by Farah Al-Tufaili 8
  • 8. variables and that they are correlated. The sample covariance matrix for these two variables is calculated as: Where x=(h w)T and x=(h w)T is the simple mean. PCA- by Farah Al-Tufaili 9
  • 9. Weight (X) Height (Y) X-mean Y-mean 65 170 -4.416666667 -3.25 75 176 5.583333333 2.75 53 154 -16.41666667 -19.25 54 167 -15.41666667 -6.25 61 171 -8.416666667 -2.25 88 184 18.58333333 10.75 70 182 0.583333333 8.75 78 190 8.583333333 16.75 52 166 -17.41666667 -7.25 95 168 25.58333333 -5.25 70 176 0.583333333 2.75 72 175 2.583333333 1.75 Mean: 69.41666667 173.25 Variance: 182.9924 90.5682 Applying the equation:   K k T xx T kk T xxx K E 1 1 }))({( mmxxmxmxC PCA- by Farah Al-Tufaili 10
  • 10. clc x=[65 75 53 54 61 88 70 78 52 95 70 72] y=[170 176 154 167 171 184 182 190 166 168 176 175] x_mean=mean(x) , y_mean=mean(y) x1=x-x_mean; y1=y-y_mean; var_x=sum(x1.^2)/(length(x)-1) var_y=sum(y1.^2)/(length(y)-1) cv=(x1).*(y1); cov=sum(cv)/(length(x)-1) Output: x_mean = 69.4167 y_mean = 173.2500 var_x = 182.9924 var_y = 90.5682 cov = 73.4318 PCA- by Farah Al-Tufaili 11
  • 11. • The basic aim of PCA is to effect a rotation of the coordinate system and thereby express the data in terms of a new set of variables or equivalently axes which are uncorrelated. • How are these found? The first principal axis is chosen to satisfy the following criterion: • The axis passing through the data points which maximizes the sum of the squared lengths of the perpendicular projection of the data points onto that axis is the principal axis. PCA- by Farah Al-Tufaili 12
  • 12. Figure 9.7 Distribution of weight and height values within a 2-D feature space. The mean value of each variable has been subtracted from the data PCA- by Farah Al-Tufaili 13
  • 13. Thus, the principal axis is oriented so as to maximize the overall variance of the data with respect to it (a variance-maximizing transform). We note in passing that an alternative but entirely equivalent criterion for a principal axis is that it minimizes the sum of the squared errors (differences) between the actual data points and their perpendicular projections onto the said straight line. This concept is illustrated in Figure 9.8. Let us suppose that the first principal axis has been found. To calculate the second principal axis we proceed as follows:  Calculate the projections of the data points onto the first principal axis.  Subtract these projected values from the original data. The modified set of data points is termed the residual data.  The second principal axis is then calculated to satisfy an identical criterion to the first (i.e. the variance of the residual data is maximized along this axis). PCA- by Farah Al-Tufaili 14
  • 14. Note also that this is distinct from fitting a straight line by regression. In regression, x is an independent variable and y the dependent variable and we seek to minimize the sum of the squared errors between the actual y values and their predicted values. PCA- by Farah Al-Tufaili 15
  • 15. PCA- by Farah Al-Tufaili 16
  • 16. In fact, this alignment is precisely the mechanism that decorrelatcs the data. Furthermore, as the eigenvalues appear along the main diagonal of Cy ,λ i is the variance of component yi along eigenvector ei . The two eigenvectors are perpendicular. The y-axes sometimes are called the eigen axes for obvious reasons. PCA- by Farah Al-Tufaili 17
  • 17.  let the covariance matrix is : 7 3 3 −1  First Step: compute eigenvalues. To do this, we find the values of which satisfy the characteristic equation of the matrix A, namely those values of for which det(A − I) = 0, 1. λ I= λ 1 0 0 1 = λ 0 0 λ 2. A- λI= 7 3 3 −1 - λ 0 0 λ = 7 − λ 3 3 −1 − λ 3. det 7 3 3 −1 = (7- λ)(-1- λ)-(3)(3)= -7-7λ+λ+ λ2-9= λ2-6 λ-16 (λ-8)(λ+2)=0 λ1=8 λ2=-2 EigenValues Let this equation equal to zero and solve it PCA- by Farah Al-Tufaili 18
  • 18.  Second step: find corresponding eigenvectors. 1. For each eigenvalue λ, we have (A − λ I)V = 0, where x is the eigenvector associated with eigenvalue λ. 2. Find x by Gaussian elimination. That is, convert the augmented matrix (A − λ I ⋮ 0) to row echelon form, and solve the resulting linear system by back substitution. We find the eigenvectors associated with each of the eigenvalues PCA- by Farah Al-Tufaili 19
  • 19. −1𝑣1+ 3𝑣2 = 0 ………..(1 3𝑣1- 9𝑣2 = 0 ………..(2 2𝑣1- 6𝑣2 = 0 ………..(3 Lets 𝑠 = (2)2+(−6)2=6.3246 v1 = 2/6.3246= 0.3162 v2 = -6/6.3246= -0.9487 PCA- by Farah Al-Tufaili 20 When λ1=8 A- λI= 7 − 8 3 3 −1 − 8 = −1 3 3 −9 (A − λ I)V = 0 −1 3 3 −9 ⋮ 𝑣1 𝑣2 =0 −𝟏 × 𝐯 𝟏 + 𝟑 × 𝐯 𝟐 = 𝟎 𝟑 × 𝐯 𝟏 + −𝟗 × 𝐯 𝟐 = 𝟎
  • 20. PCA- by Farah Al-Tufaili 21 9𝑣1+ 3𝑣2 = 0 ………..(1 3𝑣1+1𝑣2 = 0 ………..(2 6𝑣1+2𝑣2 = 0 ………..(3 Lets 𝑠 = (2)2+(6)2=6.3246 v1 = -6/6.3246= -0.9487 v2 = -2/6.3246= -0.3162 When λ1=-2 A- λI= 7 + 2 3 3 −1 + 2 = 9 3 3 1 (A − λ I)V = 0 9 3 3 1 ⋮ 𝑣1 𝑣2 =0 𝟗 × 𝐯 𝟏 + 𝟑 × 𝐯 𝟐 = 𝟎 𝟑 × 𝐯 𝟏 + 𝟏 × 𝐯 𝟐 = 𝟎
  • 21. check our solution in Matlab: >> x=[7 3;3 -1] x = 7 3 3 -1 >>[a b]=eig(x) a = 0.3162 -0.9487 -0.9487 -0.3162 b = -2 0 0 8 PCA- by Farah Al-Tufaili 22 EigenValues EigenVictor
  • 22.  There is a subtle difference between the two alternative derivations we have offered. In the first case we considered our variables to define the feature space and derived a set of principal axes. The dimensionality of our feature space was determined by the number of variables and the diagonalizing matrix of eigenvectors R to produce a new set of axes in that 2-D space. Our second formulation leads to essentially the same procedure (i.e. to diagonalize the covariance matrix), but it nonetheless admits an alternative viewpoint. In this instance, we view the observations on each of the variables to define our (higher dimensional) feature vectors. The role of the diagonalizing matrix of eigenvectors R here is thus to multiply and transform these higher dimensional vectors to produce a new orthogonal (principal) set. Thus, the dimensionality of the space here is determined by the number of observations made on each of the variables. PCA- by Farah Al-Tufaili 23
  • 23. W=[65 75 53 54 61 88 70 78 52 95 70 72]' %1. Form data vector on weight H=[170 176 154 167 171 184 182 190 166 168 176 175]' %Form data vector on height XM=[mean(W).*ones(length(W),1) mean(H).*ones(length(H),1)] %matrix with mean values replicated X=[W H]-XM %Form mean-subtracted data matrix Cx=cov(X) %calculate covariance on data [R,LAMBDA,Q]=svd(Cx) %Get eigenvalues LAMBDA and eigenvectors R V=X*R %Calculate principal components subplot(1,2,1), plot(X(:,1),X(:,2),'ko'); grid on; %2. display data on original axes subplot(1,2,2), plot(V(:,1),V(:,2),'ro'); grid on; %display PCs as data in rotated space XR=XM+V*R' %3. Reconstruct data in terms of PCs XR-[W H] %Confirm reconstruction (diff = 0) V'*V./(length(W)-1) %4. Confirm covariance terms %MATLAB FUNCTIONS cov, mean, svd, PCA- by Farah Al-Tufaili 24
  • 24. The weight–height data referred to the original axes x1 and x2 and to the principal axes v1 and v2 PCA- by Farah Al-Tufaili 25
  • 25. • It is self-evident that the basic placement, size and shape of human facial features are similar. Therefore, we can expect that an ensemble of suitably scaled and registered images of the human face will exhibit fairly strong correlation. Each image consisted of 21 054 grey-scale pixel values. Figure 9.13 A sample of human faces scaled and registered such that each can be described by the same number of pixels (21 054). PCA- by Farah Al-Tufaili 26
  • 26. Figure 9.15 The first six facial principal components from a sample of 290 faces. The first principal is the average face. Note the strong male appearance coded by principal component no. 3 PCA- by Farah Al-Tufaili 27
  • 27. Any Questions? PCA- by Farah Al-Tufaili 28