Face Recognition
Face recognition of known person is easy job for a human
brain but for a computer system it is bit difficult. Human brain has special
nerves that see the world as a whole image not in scatter pieces. Face has some
inner features
I.
Nose
II.
Lips
III.
Eyes
And some outer features
I.
Head
II.
Shape
III.
Hairline
Face recognition is
all about extracting those feature and recognize the image. In this project two
techniques are used to reduce the dimensionality of the image. After reducing
the dimensionality fro classification k-nearest neighbor is used.
Face Database
In this project take five pictures of ten people is
used while they were talking. Every image is 180×200. Different images of these
ten people are taken for the testing purpose. This data base of images is
maintained by Dr Libor Spacek.
Reading the images
First step is reading the images from the folder. Give
direct path of the training folder. Read all the images, names and label them.
After this break the image into a vector and make a matrix which has all images
vector. Structure of the matrix is given below.
X=
|
IMAGE VECTOR
1
|
IMAGE VECTOR
2
|
…………...
|
IMAGE VECTOR
n
|
One vector has dimension 3600×1 and matrix has dimension
3600×50.
Principle Component Analysis
Now every pixel of image is a feature so it is 3600
dimensional space. To reduce the dimension PCA feature extraction is used.
Algorithmic steps are given below
1.
Compute the mean of every row.
2.
Compute the Covariance Matrix S
S= XT X
3.
Compute the Eigen values λi and
eigenvectors vi of S
4.
Order the eigenvectors descending by their Eigen
value. Find the eigenvectors corresponding to the largest Eigen values. They
give the largest change.
5.
Multiply data matrix ‘A’ with matrix of Eigen
vector to get ‘W’.
6.
Output matrix calculate by
Y = WT (x -
µ)
7.
The reconstruction from the PCA
is given by
X = W(y + µ)
We know that S= X XT but if dimension of feature
are greater than then sample ‘S’ has dimension 3600×3600. So to reduce the memory
requirement, use S= XT X it has dimension 3600×50. To get the
original eigenvectors of S = XXT with a left multiplication of the
data matrix.
XTX (Xvi) = λi(Xvi)
Eigen faces are given below.
Figure 1(a) Figure 1(b)
Eigen faces
Fisher discernment analysis
The PCA finds a linear combination of features that
maximizes the total variance in data. While this is clearly a powerful way to
represent data, it doesn't consider any classes and so a lot of discriminative
information may be lost when throwing components away. Imagine a situation
where the variance is generated by an external source. The components
identified by a PCA do not necessarily contain any discriminative information
at all. In order to find the combination of features that separates best
between classes FDA is used. The Linear Discriminate Analysis maximizes the
ratio of between classes to within classes scatter. In this analysis same class
cluster remain together while different classes are as far away as possible
from each other.
Algorithic discription is given
below.
1.
The scatter matrices SB and SW are
calculated as
2.
Fisher's classic algorithm now looks for a
projection W, that maximizes
the class reparability criterion
There's one problem left to solve: The rank of SW is at most (N-c),
with N samples and c classes. In pattern recognition
problems the number of samples N is
almost always smaller than the dimension of the input data (the number of
pixels), so the scatter matrix SW becomes singular. In this was
solved by performing a Principal Component Analysis on the data and projecting
the samples into the (N-c)
dimensional space. A Linear Discriminant Analysis was then performed on the
reduced data, because SW isn't singular anymore. The
optimization problem can be rewritten as:
The transformation matrix W, that projects a sample into the (c-1)-dimensional
space is then given by:
K nearest neighbor
The k-nearest neighbor
algorithm (k-NN) is
a method for classifying objects based on closest training
examples in the feature space.
To
see the sample in feature space only three Eigen vector are taken in FLD
process. So we can see the sample in 3D space. Plot is given below. In the plot
ten objects are shown. Five sample of every object is very close to each other
and make a cluster. These objects can easily be differentiated by taking the
Euclidian distance from the testing image.
Figure 2 (3 dimensional feature space)
If someone require help inbox me
0 comments:
Post a Comment