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 and lda
Principal component analysis and ldaPrincipal component analysis and lda
Principal component analysis and ldaSuresh Pokharel
 
Introduction to Principle Component Analysis
Introduction to Principle Component AnalysisIntroduction to Principle Component Analysis
Introduction to Principle Component AnalysisSunjeet Jena
 
Dimensionality Reduction
Dimensionality ReductionDimensionality Reduction
Dimensionality ReductionSaad Elbeleidy
 
Spatial interpolation techniques
Spatial interpolation techniquesSpatial interpolation techniques
Spatial interpolation techniquesManisha Shrivastava
 
Independent Component Analysis
Independent Component AnalysisIndependent Component Analysis
Independent Component AnalysisTatsuya Yokota
 
Image Filtering in the Frequency Domain
Image Filtering in the Frequency DomainImage Filtering in the Frequency Domain
Image Filtering in the Frequency DomainAmnaakhaan
 
Image enhancement ppt nal2
Image enhancement ppt nal2Image enhancement ppt nal2
Image enhancement ppt nal2Surabhi Ks
 
Dimensionality Reduction
Dimensionality ReductionDimensionality Reduction
Dimensionality Reductionmrizwan969
 
Operations in Digital Image Processing + Convolution by Example
Operations in Digital Image Processing + Convolution by ExampleOperations in Digital Image Processing + Convolution by Example
Operations in Digital Image Processing + Convolution by ExampleAhmed Gad
 
Image enhancement
Image enhancementImage enhancement
Image enhancementAyaelshiwi
 
Hough Transform By Md.Nazmul Islam
Hough Transform By Md.Nazmul IslamHough Transform By Md.Nazmul Islam
Hough Transform By Md.Nazmul IslamNazmul Islam
 
ImageProcessing10-Segmentation(Thresholding) (1).ppt
ImageProcessing10-Segmentation(Thresholding) (1).pptImageProcessing10-Segmentation(Thresholding) (1).ppt
ImageProcessing10-Segmentation(Thresholding) (1).pptVikramBarapatre2
 
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
 
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
 
Histogram Processing
Histogram ProcessingHistogram Processing
Histogram ProcessingAmnaakhaan
 
Chapter 4 Image Processing: Image Transformation
Chapter 4 Image Processing: Image TransformationChapter 4 Image Processing: Image Transformation
Chapter 4 Image Processing: Image TransformationVarun Ojha
 

What's hot (20)

Principal component analysis and lda
Principal component analysis and ldaPrincipal component analysis and lda
Principal component analysis and lda
 
Introduction to Principle Component Analysis
Introduction to Principle Component AnalysisIntroduction to Principle Component Analysis
Introduction to Principle Component Analysis
 
Dimensionality Reduction
Dimensionality ReductionDimensionality Reduction
Dimensionality Reduction
 
Spatial interpolation techniques
Spatial interpolation techniquesSpatial interpolation techniques
Spatial interpolation techniques
 
PCA
PCAPCA
PCA
 
Independent Component Analysis
Independent Component AnalysisIndependent Component Analysis
Independent Component Analysis
 
Image Filtering in the Frequency Domain
Image Filtering in the Frequency DomainImage Filtering in the Frequency Domain
Image Filtering in the Frequency Domain
 
Unit ii
Unit iiUnit ii
Unit ii
 
Image enhancement ppt nal2
Image enhancement ppt nal2Image enhancement ppt nal2
Image enhancement ppt nal2
 
Region based segmentation
Region based segmentationRegion based segmentation
Region based segmentation
 
Dimensionality Reduction
Dimensionality ReductionDimensionality Reduction
Dimensionality Reduction
 
Operations in Digital Image Processing + Convolution by Example
Operations in Digital Image Processing + Convolution by ExampleOperations in Digital Image Processing + Convolution by Example
Operations in Digital Image Processing + Convolution by Example
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
 
Hough Transform By Md.Nazmul Islam
Hough Transform By Md.Nazmul IslamHough Transform By Md.Nazmul Islam
Hough Transform By Md.Nazmul Islam
 
ImageProcessing10-Segmentation(Thresholding) (1).ppt
ImageProcessing10-Segmentation(Thresholding) (1).pptImageProcessing10-Segmentation(Thresholding) (1).ppt
ImageProcessing10-Segmentation(Thresholding) (1).ppt
 
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
 
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
PcaPca
Pca
 
Histogram Processing
Histogram ProcessingHistogram Processing
Histogram Processing
 
Chapter 4 Image Processing: Image Transformation
Chapter 4 Image Processing: Image TransformationChapter 4 Image Processing: Image Transformation
Chapter 4 Image Processing: Image Transformation
 

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

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
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxUmerFayaz5
 
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
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxgindu3009
 
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
 
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
 
Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Nistarini College, Purulia (W.B) India
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfSumit Kumar yadav
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )aarthirajkumar25
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfmuntazimhurra
 
G9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptG9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptMAESTRELLAMesa2
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Sérgio Sacani
 
Artificial Intelligence In Microbiology by Dr. Prince C P
Artificial Intelligence In Microbiology by Dr. Prince C PArtificial Intelligence In Microbiology by Dr. Prince C P
Artificial Intelligence In Microbiology by Dr. Prince C PPRINCE C P
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​kaibalyasahoo82800
 
Broad bean, Lima Bean, Jack bean, Ullucus.pptx
Broad bean, Lima Bean, Jack bean, Ullucus.pptxBroad bean, Lima Bean, Jack bean, Ullucus.pptx
Broad bean, Lima Bean, Jack bean, Ullucus.pptxjana861314
 
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...Sérgio Sacani
 
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
 
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
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfSumit Kumar yadav
 

Recently uploaded (20)

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
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptx
 
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...
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
 
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
 
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
 
Engler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomyEngler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomy
 
Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdf
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdf
 
G9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptG9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.ppt
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
 
Artificial Intelligence In Microbiology by Dr. Prince C P
Artificial Intelligence In Microbiology by Dr. Prince C PArtificial Intelligence In Microbiology by Dr. Prince C P
Artificial Intelligence In Microbiology by Dr. Prince C P
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​
 
Broad bean, Lima Bean, Jack bean, Ullucus.pptx
Broad bean, Lima Bean, Jack bean, Ullucus.pptxBroad bean, Lima Bean, Jack bean, Ullucus.pptx
Broad bean, Lima Bean, Jack bean, Ullucus.pptx
 
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
 
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
 
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
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdf
 

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