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

Principal Component Analysis (PCA) and LDA PPT Slides
Principal Component Analysis (PCA) and LDA PPT SlidesPrincipal Component Analysis (PCA) and LDA PPT Slides
Principal Component Analysis (PCA) and LDA PPT SlidesAbhishekKumar4995
 
Lect5 principal component analysis
Lect5 principal component analysisLect5 principal component analysis
Lect5 principal component analysishktripathy
 
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
 
Principal Component Analysis and Clustering
Principal Component Analysis and ClusteringPrincipal Component Analysis and Clustering
Principal Component Analysis and ClusteringUsha Vijay
 
Maximum Likelihood Estimation
Maximum Likelihood EstimationMaximum Likelihood Estimation
Maximum Likelihood Estimationguestfee8698
 
1.8 discretization
1.8 discretization1.8 discretization
1.8 discretizationKrish_ver2
 
NAIVE BAYES CLASSIFIER
NAIVE BAYES CLASSIFIERNAIVE BAYES CLASSIFIER
NAIVE BAYES CLASSIFIERKnoldus Inc.
 
PCA (Principal component analysis)
PCA (Principal component analysis)PCA (Principal component analysis)
PCA (Principal component analysis)Learnbay Datascience
 
Logistic regression
Logistic regressionLogistic regression
Logistic regressionsaba khan
 
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
 
Fuzzy Set Theory
Fuzzy Set TheoryFuzzy Set Theory
Fuzzy Set TheoryAMIT KUMAR
 
Lecture 18: Gaussian Mixture Models and Expectation Maximization
Lecture 18: Gaussian Mixture Models and Expectation MaximizationLecture 18: Gaussian Mixture Models and Expectation Maximization
Lecture 18: Gaussian Mixture Models and Expectation Maximizationbutest
 
Decision trees in Machine Learning
Decision trees in Machine Learning Decision trees in Machine Learning
Decision trees in Machine Learning Mohammad Junaid Khan
 
Polynomial regression
Polynomial regressionPolynomial regression
Polynomial regressionnaveedaliabad
 
Classification Based Machine Learning Algorithms
Classification Based Machine Learning AlgorithmsClassification Based Machine Learning Algorithms
Classification Based Machine Learning AlgorithmsMd. Main Uddin Rony
 
Linear discriminant analysis
Linear discriminant analysisLinear discriminant analysis
Linear discriminant analysisBangalore
 
PCA (Principal Component Analysis)
PCA (Principal Component Analysis)PCA (Principal Component Analysis)
PCA (Principal Component Analysis)Luis Serrano
 

What's hot (20)

Principal Component Analysis (PCA) and LDA PPT Slides
Principal Component Analysis (PCA) and LDA PPT SlidesPrincipal Component Analysis (PCA) and LDA PPT Slides
Principal Component Analysis (PCA) and LDA PPT Slides
 
Lect5 principal component analysis
Lect5 principal component analysisLect5 principal component analysis
Lect5 principal component analysis
 
Pca
PcaPca
Pca
 
Introduction to principal component analysis (pca)
Introduction to principal component analysis (pca)Introduction to principal component analysis (pca)
Introduction to principal component analysis (pca)
 
PCA
PCAPCA
PCA
 
Principal Component Analysis and Clustering
Principal Component Analysis and ClusteringPrincipal Component Analysis and Clustering
Principal Component Analysis and Clustering
 
Maximum Likelihood Estimation
Maximum Likelihood EstimationMaximum Likelihood Estimation
Maximum Likelihood Estimation
 
1.8 discretization
1.8 discretization1.8 discretization
1.8 discretization
 
NAIVE BAYES CLASSIFIER
NAIVE BAYES CLASSIFIERNAIVE BAYES CLASSIFIER
NAIVE BAYES CLASSIFIER
 
PCA (Principal component analysis)
PCA (Principal component analysis)PCA (Principal component analysis)
PCA (Principal component analysis)
 
Logistic regression
Logistic regressionLogistic regression
Logistic regression
 
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
 
Fuzzy Set Theory
Fuzzy Set TheoryFuzzy Set Theory
Fuzzy Set Theory
 
Lecture 18: Gaussian Mixture Models and Expectation Maximization
Lecture 18: Gaussian Mixture Models and Expectation MaximizationLecture 18: Gaussian Mixture Models and Expectation Maximization
Lecture 18: Gaussian Mixture Models and Expectation Maximization
 
Decision trees in Machine Learning
Decision trees in Machine Learning Decision trees in Machine Learning
Decision trees in Machine Learning
 
Polynomial regression
Polynomial regressionPolynomial regression
Polynomial regression
 
Classification Based Machine Learning Algorithms
Classification Based Machine Learning AlgorithmsClassification Based Machine Learning Algorithms
Classification Based Machine Learning Algorithms
 
Random forest
Random forestRandom forest
Random forest
 
Linear discriminant analysis
Linear discriminant analysisLinear discriminant analysis
Linear discriminant analysis
 
PCA (Principal Component Analysis)
PCA (Principal Component Analysis)PCA (Principal Component Analysis)
PCA (Principal Component Analysis)
 

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

SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxSOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxkessiyaTpeter
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bSérgio Sacani
 
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
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfmuntazimhurra
 
Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Patrick Diehl
 
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
 
Boyles law module in the grade 10 science
Boyles law module in the grade 10 scienceBoyles law module in the grade 10 science
Boyles law module in the grade 10 sciencefloriejanemacaya1
 
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.aasikanpl
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​kaibalyasahoo82800
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTSérgio Sacani
 
Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfSumit Kumar yadav
 
Isotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoIsotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoSérgio Sacani
 
A relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfA relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfnehabiju2046
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsAArockiyaNisha
 
Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)PraveenaKalaiselvan1
 
Cultivation of KODO MILLET . made by Ghanshyam pptx
Cultivation of KODO MILLET . made by Ghanshyam pptxCultivation of KODO MILLET . made by Ghanshyam pptx
Cultivation of KODO MILLET . made by Ghanshyam pptxpradhanghanshyam7136
 
Orientation, design and principles of polyhouse
Orientation, design and principles of polyhouseOrientation, design and principles of polyhouse
Orientation, design and principles of polyhousejana861314
 
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
 
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Grafana in space: Monitoring Japan's SLIM moon lander  in real timeGrafana in space: Monitoring Japan's SLIM moon lander  in real time
Grafana in space: Monitoring Japan's SLIM moon lander in real timeSatoshi NAKAHIRA
 

Recently uploaded (20)

SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxSOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
 
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...
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdf
 
Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?
 
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...
 
Boyles law module in the grade 10 science
Boyles law module in the grade 10 scienceBoyles law module in the grade 10 science
Boyles law module in the grade 10 science
 
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOST
 
Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdf
 
Isotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoIsotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on Io
 
A relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfA relative description on Sonoporation.pdf
A relative description on Sonoporation.pdf
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based Nanomaterials
 
Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)
 
Cultivation of KODO MILLET . made by Ghanshyam pptx
Cultivation of KODO MILLET . made by Ghanshyam pptxCultivation of KODO MILLET . made by Ghanshyam pptx
Cultivation of KODO MILLET . made by Ghanshyam pptx
 
Orientation, design and principles of polyhouse
Orientation, design and principles of polyhouseOrientation, design and principles of polyhouse
Orientation, design and principles of polyhouse
 
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
 
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Grafana in space: Monitoring Japan's SLIM moon lander  in real timeGrafana in space: Monitoring Japan's SLIM moon lander  in real time
Grafana in space: Monitoring Japan's SLIM moon lander in real time
 
9953056974 Young Call Girls In Mahavir enclave Indian Quality Escort service
9953056974 Young Call Girls In Mahavir enclave Indian Quality Escort service9953056974 Young Call Girls In Mahavir enclave Indian Quality Escort service
9953056974 Young Call Girls In Mahavir enclave Indian Quality Escort service
 

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