function [timeelapsed1] = matfileforallimages()%create .mat file and calculates weights of each binary image in the database
clc;clear all;% database veins
nuser=4;nrep=6;path='C:\Program Files\MATLAB\R2013a\bin\img\PCA\my_PhD_Programs\DorsalVeinsDEMO\templates';for iuser=1:nuser for irep=1:nrep nfichd=['binaryROImano-',num2str(iuser,'%.3d'),'-',num2str(irep,'%.3d')]; nfichd=[path,'\',nfichd,'.bmp']; image1=imread(nfichd,'bmp'); %cd ..
timeelapsed1=cputime; [irow,icol]=size(image1); S=reshape(image1, irow*icol, 1); %image mean
imoy=[]; imoy=mean(S,2); S=double(S); %eigen values and eigen vectors for the matrix L=S'S
L=S'*S; [vv dd]=eig(L); 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 eigen values of L=S'S
[dtemp index]=sort(d,'descend'); for i=1:length(d) vtemp(:,i)=v(:,index(i)); end d=dtemp; v=vtemp; %normalize eigen vectors of L=S'S
for i=1:size(v,2) kk=v(:,i); temp=sqrt(sum(kk.^2)); v(:,i)=v(:,i)./temp; end %eigen values and eigen vectors for the covariance matrix C=SS'
u=[]; for i=1:size(v,2) temp=sqrt(d(i)); u=[u (S*v(:,i))./temp]; end %normalize eigen vectors of C
for i=1:size(u,2) kk=u(:,i); temp=sqrt(sum(kk.^2)); u(:,i)=u(:,i)./temp; end %number of eliminated components from the eigen base
nb=0; %weights of database's images
omega=[]; for h=1:size(S,2) ww=[]; for i=1:size(u,2)-nb t=u(:,i); Weight=dot(t,S(:,h)'); ww=[ww;Weight]; end omega=[omega,ww]; end M=4; save('omega1', 'omega', 'imoy', 'u', 'nb', 'M') %omega contains the extracted features of database images
endend
MATLAB: I want to read 24 images and stores value of omega,imou,nb into mat file, but some error in the program…
matrix read
Best Answer