%%Module Training
clc; clear all; close all; [fname path]=uigetfile('.jpg','Open a Face as input for Training'); fname=strcat(path,fname); img=imread(fname); imshow(img); %%drawnow;
title('Input Face'); c=input('Enter the Class '); %%Feature Extraction
F = FeatureStatistical(img); try S = load('db.mat'); F=[F c]; db=[db;F]; save db.mat db catch F=reshape(F,[3,2]); F=reshape(F,[1,6]); db=[F c]; save db.mat db end %%FeatureStatistical
function [F]= FeatureStatistical(img) img=double(img); mn=mean(mean(img)); sd=std(std(img)); F=[mn sd]; %%FaceClassifier
clc; clear all; close all; [fname path]=uigetfile('.jpg','Provide a Face for Testing'); fname=strcat(path,fname); img=imread(fname); imshow(img); title('Test Face'); Ftest = FeatureStatistical(img); load db.mat Ftrain=db(:,1:2); Ctrain=db(:,7); for(i=1:size(Ftrain,1)) dist(i,:)=sum(abs(Ftrain(i,:)-Ftest)); end Min=min(dist); if(Min<3) m=find(dist==Min,1); det_class=Ctrain(m); msgbox(strcat('Detected Class= ',num2str(det_class))); else msgbox('Not Same'); end
MATLAB: Hi! Would you please help me :] the db.mat only save the last input image value. this don’t give multiple images input values.
help
Best Answer