clear all close all clc addpath('../Functions'); imgSz=128; % Lateral Image pixel size %imgSzSq=imgSz^2; % Square Image pixel size Ntr=1e6; % Number of pictures train set Ntests=1e4; % Number of pictures test set %fileOffsetPic=16; % Bytes of pictures file offset %fileOffsetLab=8; % Bytes of label file offset ENNSon=1; % fprintf('Loading data... \n'); XSet=fvecs_read('../Data/sift/sift_base.fvecs'); YSet=fvecs_read('../Data/sift/sift_query.fvecs'); %YLab=ivecs_read('../Data/sift/sift_groundtruth.ivecs'); break; %% Reading Binary Training Images and Labels % % [XSet, XLab]=ReadingPicSetLabSet(imgSz, Ntr, fileOffsetPic, '../Data/train-images.idx3-ubyte',... % fileOffsetLab, '../Data/train-labels.idx1-ubyte', 0); % %% Reading Binary Testing Images and Labels % [YSet, YLab]=ReadingPicSetLabSet(imgSz, Ntests, fileOffsetPic, '../Data/t10k-images.idx3-ubyte',... % fileOffsetLab, '../Data/t10k-labels.idx1-ubyte', 0); %% Computing NNS with Euclidean Distance if(ENNSon) fprintf('Computing Euclidean NNS: ... '); dEuc=zeros(1,Ntr); indmin=zeros(1,Ntests); for ii=1:Ntests for jj=1:Ntr Xjj=XSet(imgSz*(jj-1)+1:imgSz*jj); Yii=YSet(imgSz*(ii-1)+1:imgSz*ii); dEuc(jj)=sum((Xjj-Yii).^2); end [~,indmin(ii)]=min(dEuc); fprintf('\b\b\b\b\b\b%3.2f %%',ii/Ntests*100); end save('indminEuNNS.mat','indmin'); else fprintf('Loading Euclidean NNS results ...'); load('indminEuNNS.mat') end %% Plot some of the matches %Nstart=9983; %for kk=Nstart+1:Nstart+10%Ntests %subplot(2,10,kk-Nstart) %imshow255(0,imgSz,YSet') %xlabel(int2str(YLab(kk))); %title('Test Image') %subplot(2,10,kk-Nstart+10) %figure() %imshow255(0,imgSz,XSet(indmin(1))') %xlabel(int2str(XLab(indmin(kk)))); %title('Match Image') %end %NErrors=Ntests-sum(XLab(indmin)==YLab(1:length(indmin))); %Performances=100-NErrors/Ntests*100