Professional Documents
Culture Documents
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
axes(handles.axes4)
cla
axes(handles.axes3)
cla
handles.output = hObject;
% addpath(genpath([pwd '\']));
% Update handles structure
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = pengenalan_pola_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes3)
cla
axes(handles.axes4)
cla
axes(handles.axes3)
imshow(TestImage);
title('Test Image','Color','Black','FontSize',15);
axes(handles.axes4)
imshow(selected_img);
title('Detected','Color','red','FontSize',15);
set(handles.togglebutton10,'visible','on');
set(handles.togglebutton11,'visible','on');
while 1
pause(eps);
if get(handles.togglebutton10,'value')==1
IsTrue=IsTrue+1;
set(handles.togglebutton10,'value',0)
break;
elseif get(handles.togglebutton11,'value')==1
set(handles.togglebutton11,'value',0)
break;
end
end
set(handles.togglebutton10,'visible','off');
set(handles.togglebutton11,'visible','off');
end
eta = (IsTrue/gambar)*100;
set(handles.edit2,'visible','on');
set(handles.text4,'visible','on');
set(handles.edit2,'String',[num2str(eta)]);
drawnow;
set(handles.text5,'visible','off');
axes(handles.axes3)
cla
axes(handles.axes4)
cla
axes(handles.axes3)
imshow(test_image);
title('Test Image','Color','Black','FontSize',15);
axes(handles.axes4)
imshow(selected_img);
title('Detected','Color','red','FontSize',15);
function [recognized_img]=facerecog(datapath,testimg)
% 1) Data-base construction
X = [];
for i = 1 : imgcount
str = strcat(datapath,'\',int2str(i),'.jpg');
img = imread(str);
[r c] = size(img);
temp = reshape(img',r*c,1); %Reshaping 2D images into 1D image vectors
X = [X temp];
end
% 2) Finding mean-image
m = mean(X,2);
imgcount = size(X,2);
% 8) Miniature database
projectimg = [ ]; % projected image vector matrix
for i = 1 : size(eigenfaces,2)
temp = eigenfaces' * A(:,i);
projectimg = [projectimg temp];
end
% Testing:
% 9) Finding test image projecttion
test_image = imread(testimg);
test_image = test_image(:,:,1);
[r c] = size(test_image);
temp = reshape(test_image',r*c,1); % creating (MxN)x1 image vector from the 2D
image
temp = double(temp)-m; % mean subtracted vector
projtestimg = eigenfaces'*temp; % projection of test image onto the space