0% found this document useful (0 votes)
47 views

Matlab

matlab

Uploaded by

thangam8891
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

Matlab

matlab

Uploaded by

thangam8891
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 13

MPLEMENTATION AND RESULTS

4.1 Introduction:
In previous chapters (chapter 2 and chapter 3), we get the theoretical knowledge about the Principal
Component Analysis and Discrete Cosine Transform. In our thesis work we have seen the analysis of
both transform. To execute these tasks we chosen a platform called MATLAB, stands for matrix
laboratory. It is an efficient language for Digital image processing. The image processing toolbox in
MATLAB is a collection of different MATAB functions that extend the capability of the MATLAB
environment for the solution of digital image processing problems. [13]

Get help with your essay


Read more about our Essay Writing Service >

Looking for examples of OUR work?


Click here to see our Essay Writing Examples >

Want to know more about our services?


Take a look at our Writing & Marking Service Index >

4.2 Practical implementation of Performance analysis:


As discussed earlier we are going to perform analysis for the two transform methods, to the images as,
Principal Component Analysis
Discrete Cosine Transform
In order to perform the analysis for these transform techniques we follow the steps.
First we have to read the real fringe pattern as shown in Figure 4.1 by using the following syntax,
a=input('enter the Input image: \n', 's');
img=imread(a);
This syntax is repeated again and again until we include all the images for the training, and also one
more time when we are giving the input image for testing.

The PCA is performed based on the calculation given accordingly in chapter 2, based on the
convolution method. So there are a sequence of instructions to be followed in order to perform the PCA
transform.
In the reconstruction we take the transformed image and try to get back the image based on training set.

4.3 MATLAB coding to implement Performance Analysis:


clear all;
close all;
clc;
% number of images on your training set.
M=50;
% Chosen std and mean.
% It can be any number that it is close to the std and mean of most of the images.
um=100;
ustd=80;
% read and show image
S=[]; % img matrix
figure(1);
for i=1:M
%str=strcat(int2str(i),'.bmp'); % concatenates two strings that form the name of the image
%eval('img=imread(str);');
a=input('enter the Input image: \n', 's');
img=imread(a);
subplot(ceil(sqrt(M)),ceil(sqrt(M)),i)
imshow(img)
if i==3
title('Training set','fontsize',18)
end
drawnow;
[irow icol]=size(img); % get the number of rows (N1) and columns (N2)

temp=reshape(img,irow*icol,1); % creates a (N1*N2)x1 vector


S=[S temp]; % S is a N1*N2xM matrix after finishing the sequence
end
% Here we change the mean and std of all images. We normalize all images.
% This is done to reduce the error due to lighting conditions and background.
for i=1:size(S,2)
temp=double(S(:,i));
m=mean(temp);
st=std(temp);
S(:,i)=(temp-m)*ustd/st+um;
end
% show normalized images
figure(2);
for i=1:M
str=strcat(int2str(i),'.jpg');
img=reshape(S(:,i),icol,irow);
img=img';
eval('imwrite(img,str)');
subplot(ceil(sqrt(M)),ceil(sqrt(M)),i)
imshow(img)
drawnow;
if i==3
title('Normalized Training Set','fontsize',18)
end
end
% mean image
m=mean(S,2); % obtains the mean of each row instead of each column
tmimg=uint8(m); % converts to unsigned 8-bit integer. Values range from 0 to 255
img=reshape(tmimg,icol,irow); % takes the N1*N2x1 vector and creates a N1xN2 matrix

img=img';
figure(3);
imshow(img);
title('Mean Image','fontsize',18)
% Change image for manipulation
dbx=[]; % A matrix
for i=1:M
temp=double(S(:,i));
dbx=[dbx temp];
end
%Covariance matrix C=A'A, L=AA'
A=dbx';
L=A*A';
% vv are the eigenvector for L
% dd are the eigenvalue for both L=dbx'*dbx and C=dbx*dbx';
[vv dd]=eig(L);
% Sort and eliminate those whose eigenvalue is zero
v=[];
d=[];
for i=1:size(vv,2)
if(dd(i,i)>1e-4)
v=[v vv(:,i)];
d=[d dd(i,i)];
end
end
%sort, will return an ascending sequence
[B index]=sort(d);
ind=zeros(size(index));
dtemp=zeros(size(index));

vtemp=zeros(size(v));
len=length(index);
for i=1:len
dtemp(i)=B(len+1-i);
ind(i)=len+1-index(i);
vtemp(:,ind(i))=v(:,i);
end
d=dtemp;
v=vtemp;
%Normalization of eigenvectors
for i=1:size(v,2) %access each column
kk=v(:,i);
temp=sqrt(sum(kk.^2));
v(:,i)=v(:,i)./temp;
end
%Eigenvectors of C matrix
u=[];
for i=1:size(v,2)
temp=sqrt(d(i));
u=[u (dbx*v(:,i))./temp];
end
%Normalization of eigenvectors
for i=1:size(u,2)
kk=u(:,i);
temp=sqrt(sum(kk.^2));
u(:,i)=u(:,i)./temp;
end
% show eigenfaces
figure(4);

for i=1:size(u,2)
img=reshape(u(:,i),icol,irow);
img=img';
img=histeq(img,255);
subplot(ceil(sqrt(M)),ceil(sqrt(M)),i)
imshow(img)
drawnow;
if i==3
title('Eigenfaces','fontsize',18)
end
end
% Find the weight of each face in the training set

Get help with your essay


Read more about our Essay Writing Service >

Looking for examples of OUR work?


Click here to see our Essay Writing Examples >

Want to know more about our services?


Take a look at our Writing & Marking Service Index >
omega = [];
for h=1:size(dbx,2)
WW=[];
for i=1:size(u,2)
t = u(:,i)';
WeightOfImage = dot(t,dbx(:,h)');
WW = [WW; WeightOfImage];

end
omega = [omega WW];
end
% Acquire new image
% Note: the input image must have a bmp or jpg extension.
% It should have the same size as the ones in your training set.
% It should be placed on your desktop
InputImage = input('Please enter the name of the image and its extension \n','s');
InputImage = imread(strcat('C:\Documents and Settings\DERRON\Desktop\pavan\',InputImage));
figure(5)
subplot(1,2,1)
imshow(InputImage); colormap('gray');title('Input image','fontsize',18)
I=InputImage;
InImage=reshape(double(InputImage),irow*icol,1);
temp=InImage;
me=mean(temp);
st=std(temp);
temp=(temp-me)*ustd/st+um;
NormImage = temp;
Difference = temp-m;
p = [];
aa=size(u,2);
for i = 1:aa
pare = dot(NormImage,u(:,i));
p = [p; pare];
end
ReshapedImage = m + u(:,1:aa)*p; %m is the mean image, u is the eigenvector
ReshapedImage = reshape(ReshapedImage,icol,irow);
ReshapedImage = ReshapedImage';

%show the reconstructed image.


subplot(1,2,2)
imagesc(ReshapedImage); colormap('gray');
title('Reconstructed image in PCA','fontsize',18)
% Discrete Cosine Transform
J=DCT_8X8(I); % Discrete Cosine Transform
%imshow(log(abs(J)),[]), colormap(jet), colorbar;
J(abs(J)<10) = 0;
K = IDCT_8X8(J); % Inverse DCT
figure;
subplot(1,2,1)
imshow(I);
title('Input image','fontsize',18);
subplot(1,2,2)
imshow(K,[0 255]);
title('Reconstructed image in DCT','fontsize',18)
InImWeight = [];
for i=1:size(u,2)
t = u(:,i)';
WeightOfInputImage = dot(t,Difference');
InImWeight = [InImWeight; WeightOfInputImage];
end
ll = 1:M;
figure(68)
subplot(1,2,1)
stem(InImWeight)
title('Weight of Input Face','fontsize',14)
% Find Euclidean distance
e=[];

for i=1:size(omega,2)
q = omega(:,i);
DiffWeight = InImWeight-q;
mag = norm(DiffWeight);
e = [e mag];
end
kk = 1:size(e,2);
subplot(1,2,2)
stem(kk,e)
title('Eucledian distance of input image','fontsize',14)
MaximumValue=max(e); % maximum eucledian distance
MinimumValue=min(e) % minimum eucledian distance

CHAPTER 5
CONCLUSIONS AND FUTURE WORK
5.1 Conclusions:
Using the original FERET testing protocol, a standard PCA classifier did better when using
Mahalanobis distance rather than L1, L2 or Angle. In a new set of experiments where the the training
(gallery) and testing (probe) images were selected at random over 10 trials, Mahalanobis was again
superior when 60% of the Eigenvectors were used. However, when only the first 20 Eigenvectors were
used, L2, Angle and Mahalanobis were equivalent. L1 did slightly worse.
Our efforts to combine distance measures did not result in significant performance improvement.
Moreover, the correlation among the L1, L2, Angle and Mahalanobis distance measures, and their
shared bias, suggests that although improvements may be possible by combining the L1 measure with
other measures, such improvements are likely to be small. We also compared the standard method for
selecting a subset of Eigenvectors to one based on like-image similarity. While the like-image method
seems like a good idea, it does not perform better in our experiments. More recent 10 Table 5: Number
of correctly classified images, out of 140, for different algorithm variations. Each row gives results for
a different random selection of training and test data. a) Discard last 40% of the Eigenvectors, b) Keep
only the first 20 Eigenvectors.
Standard Order Sig. Diff. Order
T L2 L1 A M L2 L1 A M

1 59 69 67 89 63 68 65 85
2 61 70 62 82 60 68 62 83
3 54 76 71 89 59 76 70 86
4 53 73 67 83 61 71 66 84
5 62 71 58 83 54 70 59 84

Get help with your essay


Read more about our Essay Writing Service >

Looking for examples of OUR work?


Click here to see our Essay Writing Examples >

Want to know more about our services?


Take a look at our Writing & Marking Service Index >
6 50 72 61 89 64 67 61 79
7 55 75 66 91 63 72 66 85
8 61 67 61 91 53 69 61 83
9 59 71 60 86 56 72 59 79
10 63 73 66 92 61 73 66 86
57.7 71.7 63.9 87.5 59.4 70.6 63.5 83.4
(a)
Standard Order Sig. Diff. Order
T L2 L1 A M L2 L1 A M

1 46 46 52 55 47 45 53 56
2 50 46 50 56 47 44 49 53
3 54 47 58 48 49 43 56 53
4 46 46 46 52 55 47 45 42
5 42 42 51 50 44 44 52 50
6 49 41 55 48 41 42 56 45
7 53 46 44 49 49 46 44 45
8 45 45 50 45 50 44 48 47
9 55 41 49 51 45 41 49 45
10 43 48 48 52 53 49 46 47
48.3 44.8 50.3 50.6 48.0 44.5 49.8 48.3
(b)
work suggests this technique works better than the standard when used in conjunction with Fischer
Discriminant analysis, but these results are still preliminary. The work presented here was done
primarily by Wendy Yambor as part of her Masters work [17]. At Colorado State, we are continuing to
study the relative performance of alternative face recognition algorithms. We have two goals. The first
being to better understand commonly used algorithms. The second, larger goal, is to develop a more
mature statistical methodology for the study of these algorithms and others like them. This more recent
work is being supported by the DARPA Human Identification at a Distance Program. As part of this
project, we are developing a web site intended to serve as a general resource for researchers wishing to
compare new algorithms to standard algorithms previously published in the literature. This web site
may be found at:
http://www.cs.colostate.edu/evalfacerec/.
Print Email Download Reference This Send to Kindle Reddit This
0 comments
Sign in or Post as Guest
1 person listening

Newest | Oldest | Top Comments

Share This Essay


To share this essay on Reddit, Facebook, Twitter, or Google+ just click on the buttons below:
submit
Tweet

Request Removal
If you are the original writer of this essay and no longer wish to have the essay published on the UK
Essays website then please click on the link below to request removal:
Request the removal of this essay.

More from UK Essays


Free Essays Index - Return to the FREE Essays Index
More Psychology Essays - More Free Psychology Essays (submitted by students)
Psychology Essay Writing Service -find out more about how we can help you
Example Psychology Essays - See examples of Psychology Essays (written by our in-house
experts)
Writing Services
Essay writing
Dissertation writing
Assignment writing
All Services
Free Content
Essay Help
Referencing Guides
All Free Resources
About UK Essays
About Us
Is this cheating?

Contact Us
Order Now
Instant Price
Search UK Essays

Read more: http://www.ukessays.com/essays/psychology/recognition-coding-for-progressive-sensorspsychology-essay.php#ixzz3AkGsFWoK

You might also like