How to modify this code to upload an image manually and match the image from stored database

1 Ansicht (letzte 30 Tage)
w=load_database();
try
ri=round(2*rand(1,1)); % Randomly pick an index.
k=w(:,ri); % k contains the image we later on will use to test the algorithm
v=w(:,[1:ri-1 ri+1:end]); % v contains the rest of the 1 images.
N=20; % Number of signatures used for each image.
%% Subtracting the mean from v
O=uint8(ones(1,size(v,2)));
m=uint8(mean(v,2)); % m is the maen of all images.
vzm=v-uint8(single(m)*single(O)); % vzm is v with the mean removed.
%% Calculating eignevectors of the correlation matrix
% We are picking N of the 10 eigenfaces.
L=single(vzm)'*single(vzm);
[V,D]=eig(L);
V=single(vzm)*V;
V=V(:,end:-1:end-(N-1)); % Pick the eignevectors corresponding to the 10 largest eigenvalues.
%% Calculating the signature for each image
cv=zeros(size(v,2),N);
for i=1:size(v,2);
cv(i,:)=single(vzm(:,i))'*V; % Each row in cv is the signature for one image.
end
%% Recognition
% Now, we run the algorithm and see if we can correctly recognize the face.
axes(handles.axes10);
%title('Looking for ...','FontWeight','bold','Fontsize',16,'color','red');
axes(handles.axes3);
p=k-m; % Subtract the mean
s=single(p)'*V;
z=[];
for i=1:size(v,2)
z=[z,norm(cv(i,:)-s,2)];
if(rem(i,20)==0),imshow(reshape(v(:,i),112,92),'Parent',handles.axes3),end;
drawnow;
end
[a,i]=min(z);
axes(handles.axes3);
imshow(reshape(v(:,i),112,92),'Parent',handles.axes3);title('Found!','FontWeight','bold','Fontsize',16,'color','red');
catch
image = imread('no.jpg');
axes(handles.axes3);
imshow(image,'Parent',handles.axes3);title('Cannot Find!','FontWeight','bold','Fontsize',16,'color','red');
end

Antworten (1)

Image Analyst
Image Analyst am 17 Dez. 2018
To upload an image, use copyfile().
To match, it depends on how exactly the two images must match.
  2 Kommentare
LAI Mom Cin
LAI Mom Cin am 17 Dez. 2018
Above the code is random pick the image from the stored databas. If I'm using GUI (filename=gui.m&gui.fig) to click button for upload the image and detect the face recognition as below example. How can I match (click button "SCAN") the face detection in the database image and come out with a "Found!" result.
guisample.png

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by