function varargout = Main(varargin) % MAIN MATLAB code for Main.fig % MAIN, by itself, creates a new MAIN or raises the existing % singleton*. % % H = MAIN returns the handle to a new MAIN or the handle to % the existing singleton*. % % MAIN('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in MAIN.M with the given input arguments. % % MAIN('Property','Value',...) creates a new MAIN or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before Main_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to Main_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help Main % Last Modified by GUIDE v2.5 02-Feb-2022 18:26:26 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @Main_OpeningFcn, ... 'gui_OutputFcn', @Main_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before Main is made visible. function Main_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to Main (see VARARGIN) % Choose default command line output for Main handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes Main wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = Main_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) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on button press in pushbutton6. function pushbutton6_Callback(hObject, eventdata, handles) % hObject handle to pushbutton6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) run('SVM_RF.m') run('FeatureReduction\Check_dta.m') % --- Executes on button press in pushbutton7. function pushbutton7_Callback(hObject, eventdata, handles) % hObject handle to pushbutton7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) cd('FeatureReduction') load out.mat if isequal(k,[]) uiwait(msgbox('Input_image was real image')) else uiwait(msgbox('Input_image was fake image')) end % --- Executes on button press in pushbutton4. function pushbutton4_Callback(hObject, eventdata, handles) % hObject handle to pushbutton4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) load DTA.mat augmenter = imageDataAugmenter( ... 'RandRotation',[0 360], ... 'RandScale',[0.5 1]) imageSize = [56 56 1]; auimds = augmentedImageDatastore(imageSize,XTrain,YTrain,'DataAugmentation',augmenter) basicwaitbar uiwait(msgbox('Image resized succuesfully')) % --- Executes on button press in pushbutton5. function pushbutton5_Callback(hObject, eventdata, handles) % hObject handle to pushbutton5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) run('FeatureReduction\feature_extraction.m') pause(10) uiwait(msgbox('feature extracted succuesfully')) % --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) path_folder= uigetdir('Please enter your respective path','fingerprint_data'); try data_dir_Fake = 'fake data path'; data_dir_real = 'real data path'; images_fake = dir([data_dir_Fake '/*.jpg']); images_real = dir([data_dir_real '/*.jpg']); score_artifacts = []; score_authentic = []; for i = 1:N IMAGE_real = imread(['real data path' images_fake(i).name]); PORE_NUMBER = BIO_PAD_FG_HOWTO(IMAGE_real); score_artifacts = [score_artifacts PORE_NUMBER]; score_all = [score_all PORE_NUMBER]; end for i = 1:N IMAGE_fake = imread(['fake data path' images_silicone(i).name]); PORE_NUMBER = Finer_Sect(IMAGE_fake); score_artifacts = [score_artifacts PORE_NUMBER]; score_all = [score_all PORE_NUMBER]; end APCER_score = []; NPCER_score = []; for n = 50:100 fault_negative = sum(score_artifacts >= prctile(score_all, n)); fault_positive = sum(score_authentic <= prctile(score_all, n)); APCER = fault_negative / length(score_artifacts); NPCER = fault_positive / length(score_authentic); APCER_score = [APCER_score APCER]; NPCER_score = [NPCER_score NPCER]; end index = find(NPCER_score == min(NPCER_score)); APCER_min = []; for i = 1 : length(index) APCER_min = [APCER_min APCER_score(i)]; end APCER = min(APCER_min); NPCER = min(NPCER_score); train_authentic = score_authentic(1:6,:); test_authentic = score_authentic(7:12,:); test_artifacts = score_artifacts; % Calculate threshold using authentic reference. authentic_ref = []; for i = 1 : length(train_authentic) authentic_score = []; for j = 1 :length(train_authentic) authentic_score = [authentic_score ... abs(train_authentic(i) - train_authentic(j))]; end authentic_ref = [authentic_ref authentic_score]; end threshold = max(authentic_ref); % Calculate distance for authentic vs. authentic references. authentic_dist = []; score = 0; for i = 1 : length(test_authentic) authentic_score = []; for j = 1 : length(train_authentic) authentic_score = [authentic_score ... abs(test_authentic(i) - train_authentic(j))]; end authentic_dist = [authentic_dist mean(authentic_score)]; end for i = 1 : length(authentic_dist) if authentic_dist(i) > threshold score = score + 1; end end NPCER = score / length(test_artifacts); % Calculate distance for artifacts vs. authentic references. artifact_dist = []; score = 0; for i = 1 : length(test_artifacts) artifact_score = []; for j = 1 : length(train_authentic) artifact_score = [artifact_score ... abs(test_artifacts(i) - train_authentic(j))]; end artifact_dist = [artifact_dist mean(artifact_score)]; end for i = 1 : length(artifact_dist) if artifact_dist(i) < threshold score = score + 1; end end [Data,~]=LOSIBF(artifact_dist,score,threshold); DATA_(2,:)=Data save('Data.mat','DATA_') end pause(5) uiwait(msgbox('Finger_print data loaded successfully')) % --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) path_folder= uigetdir('Please enter your respective path','Face_data'); pause(5) disp(path_folder) %% Loading the database into matrix v try w=load_database(); %% Initializations ri=round(400*rand(1,1)); % Randomly pick an index. r=w(:,ri); % r contains the image we later on will use to test the algorithm v=w(:,[1:ri-1 ri+1:end]); 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 400 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 [Data,~]=LOSIBF(cv,V,D); DATA_(1,:)=Data save('Data.mat','DATA_') end uiwait(msgbox('Face data loaded successfully')) % --- Executes on button press in pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) path_folder= uigetdir('Please enter your respective path','Iris_data'); % Fix the size of all images to 256x256 try subarea_size = 256; % Load iris images iris_fake_dir = dir(['../data-raw/LivDet-Iris-2013-Warsaw-Subset/fake*.png']); iris_real_dir = dir(['../data-raw/LivDet-Iris-2013-Warsaw-Subset/real*.png']); seg =[iris_fake_dir iris_real_dir] x = seg(:,1); y = seg(:,2); r =max(randi([-10 10],1,10)); % Crop the iris portion of the image subimage = image(y-subarea_size/2+1 : y+subarea_size/2, x-subarea_size/2+1 : x+subarea_size/2); %% Choose paramaters f0, f1, df f0 = 5; f1 = 40; df = 15; [rr cc] = meshgrid(1:256); C1 = sqrt((rr-256/2).^2+(cc-256/2).^2)>=f0; % start point f0 C2 = sqrt((rr-256/2).^2+(cc-256/2).^2)<=(f0+df); % end point f0+df mask1 = C1 .* C2; masked_image1 = double(subimage).* double(mask1); numerator = max(masked_image1(:)); % Create the second mask which starts at f1 and ends at f1+df C3 = sqrt((rr-256/2).^2+(cc-256/2).^2)>=f1; % start point f1 C4 = sqrt((rr-256/2).^2+(cc-256/2).^2)<=(f1+df); % end point f1+df mask2 = C3 .* C4; masked_image2 = double(subimage) .* double(mask2); denominator = max(masked_image2(:)); %% Calculate score liveness_score = numerator/denominator; [Data,~]=LOSIBF(masked_image2,df,liveness_score); DATA_(3,:)=Data save('Data.mat','DATA_') end pause(5) uiwait(msgbox('Iris data loaded successfully'))