matlab - PCA codes input, use for PalmPrint Recognition -


i'm new matlab. i'm trying apply pca function(url listed below)into palm print recognition program generate eigenpalms. palm print grey scale images dimension 450*400. before using it, trying study these codes , add codes save eigenvector .mat file. of %comments added me self understanding.

after few days of studying, still unable answers. decided ask helps.i have few questions ask regarding pca.m.

pca.m

  1. what input of "options" should be? of "pca(data,details,options)" (is integer reduced dimension? trying figure out "options" value passing, still unable ans. msgbox of "h & h2", check codes run until where. trying use integer of 10, pca.m processed dimension 400*400.)

  2. the "eigvector" save ".mat" file ready perform euclidean distance classifier other eigenvector? (i'm thinking eigvector equal eigenpalm, in face recognition, eigen faces. trying convert eigenvector matrix image, image after pca process in black , many dots on it)

mysvd.m

  1. in function, there 2 values can changed, max_matrix_size set 1600 , eigvector_ratio set 0.1%. may know these values affect results? ( trying play around values, cant see different. palm print image dimension set 450*400, max_matrix_size should set @ 180,000?)

** hope guys able understand i'm asking, please help, guys (=

original version : http://www.cad.zju.edu.cn/home/dengcai/data/code/pca.m

mysvd: http://www.cad.zju.edu.cn/home/dengcai/data/code/mysvd.m

% edited version me function [eigvector, eigvalue] = pca(data,details,options) %pca    principal component analysis % %   usage: %       [eigvector, eigvalue] = pca(data, options) %       [eigvector, eigvalue] = pca(data) % %             input: %               data       - data matrix. each row vector of fea data point. %                            fea = finite element analysis ????? %     options.reduceddim   - dimensionality of reduced subspace. if 0, %                         dimensions kept. %                         default 0. % %             output: %               eigvector - each column embedding function, new %                           data point (row vector) x,  y = x*eigvector %                           embedding result of x. %               eigvalue  - sorted eigvalue of pca eigen-problem. % %   examples: %           fea = rand(7,10); %           options=[]; %store empty matrix in options %           options.reduceddim=4; %           [eigvector,eigvalue] = pca(fea,4); %           y = fea*eigvector; % %   version 3.0 --dec/2011 %   version 2.2 --feb/2009 %   version 2.1 --june/2007 %   version 2.0 --may/2007 %   version 1.1 --feb/2006 %   version 1.0 --april/2004 % %   written deng cai (dengcai @ gmail.com) %  if (~exist('options','var'))  %a = exist('name','kind') % var = checks variables. %http://www.mathworks.com/help/matlab/matlab_prog/symbol-reference.html#bsv2dx9-1 %the tilde "~" character used in comparing arrays unequal values,  %finding logical not of array,  %and placeholder input or output argument want omit function call.       options = []; end  h2 = msgbox('not yet');  reduceddim = 0; if isfield(options,'reduceddim') %tf = isfield(s, 'fieldname')  h2 = msgbox('checked');      reduceddim = options.reduceddim; end  [nsmp,nfea] = size(data); if (reduceddim > nfea) || (reduceddim <=0)     reduceddim = nfea; end   if issparse(data)     data = full(data); end samplemean = mean(data,1); data = (data - repmat(samplemean,nsmp,1));  [eigvector, eigvalue] = mysvd(data',reduceddim); eigvalue = full(diag(eigvalue)).^2;  if isfield(options,'pcaratio')     sumeig = sum(eigvalue);     sumeig = sumeig*options.pcaratio;     sumnow = 0;     idx = 1:length(eigvalue)         sumnow = sumnow + eigvalue(idx);         if sumnow >= sumeig             break;         end     end      eigvector = eigvector(:,1:idx);  end  %dt c# program, user id , name evfolder = 'ev\'; useridname = details; %get id , name useridnamewe = strcat(useridname,'\');%get id , name extension filepath = fullfile('c:\users\***\desktop\data collection\'); useridnamefolder = strcat(filepath,useridnamewe); %id , name folder useridnameevfolder = strcat(useridnamefolder,evfolder);%ev folder in id , name folder useridnameevfile = strcat(useridnameevfolder,useridname); % ev file id , name  if ~exist(useridnameevfolder, 'dir')     mkdir(useridnameevfolder); end  newfile =  strcat(useridnameevfile,'_1'); searchmat = strcat(newfile,'.mat'); if exist(searchmat, 'file')          filepattern = strcat(useridnameevfile,'_');          d = dir([useridnameevfolder, '*.mat']);         num = length(d(not([d.isdir])))          num=num+1;         filename = [filepattern,num2str(num)];      save(filename,'eigvector');  else      newfile =  strcat(useridnameevfile,'_1');      save(newfile,'eigvector'); end 

you pass options in structure, instance:

options.reduceddim = 2; 

or

 options.pcaratio =0.4; 

the option reduceddim selects number of dimensions want use represent final projection of original matrix. instance if pick option.reduceddim = 2 use 2 eigenvectors largest eigenvalues (the 2 principal components) represent data (in effect pca return 2 eigenvectors largest eigenvalues).

pcaratio instead allows pick number of dimensions first eigenvectors largest eigenvalues account fraction pcaratio of total sum of eigenvalues.

in mysvd.m, not increase default values unless expect more 1600 eigenvectors necessary describe dataset. think can safely leave default values.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -