Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

EuclideanNNS.m 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. clear all
  2. close all
  3. clc
  4. addpath('../Functions');
  5. imgSz=28; % Lateral Image pixel size
  6. imgSzSq=imgSz^2; % Square Image pixel size
  7. Ntr=6e4; % Number of pictures train set
  8. Ntests=1e4; % Number of pictures test set
  9. fileOffsetPic=16; % Bytes of pictures file offset
  10. fileOffsetLab=8; % Bytes of label file offset
  11. ENNSon=0; %
  12. %% Reading Binary Training Images and Labels
  13. [XSet, XLab]=ReadingPicSetLabSet(imgSz, Ntr, fileOffsetPic, '../Data/train-images.idx3-ubyte',...
  14. fileOffsetLab, '../Data/train-labels.idx1-ubyte', 0);
  15. %% Reading Binary Testing Images and Labels
  16. [YSet, YLab]=ReadingPicSetLabSet(imgSz, Ntests, fileOffsetPic, '../Data/t10k-images.idx3-ubyte',...
  17. fileOffsetLab, '../Data/t10k-labels.idx1-ubyte', 0);
  18. %% Computing NNS with Euclidean Distance
  19. if(ENNSon)
  20. fprintf('Computing Euclidean NNS: ... ');
  21. dEuc=zeros(1,Ntr);
  22. indmin=zeros(1,Ntests);
  23. for ii=1:Ntests
  24. for jj=1:Ntr
  25. Xjj=XSet(imgSzSq*(jj-1)+1:imgSzSq*jj);
  26. Yii=YSet(imgSzSq*(ii-1)+1:imgSzSq*ii);
  27. dEuc(jj)=sum((Xjj-Yii).^2);
  28. end
  29. [~,indmin(ii)]=min(dEuc);
  30. fprintf('\b\b\b\b\b\b%3.2f %%',ii/Ntests*100);
  31. end
  32. else
  33. fprintf('Loading Euclidean NNS results ...');
  34. load('indminEuNNS.mat')
  35. end
  36. %% Plot some of the matches
  37. %Nstart=9983;
  38. %for kk=Nstart+1:Nstart+10%Ntests
  39. %subplot(2,10,kk-Nstart)
  40. %imshow255(0,imgSz,YSet')
  41. %xlabel(int2str(YLab(kk)));
  42. %title('Test Image')
  43. %subplot(2,10,kk-Nstart+10)
  44. %figure()
  45. %imshow255(0,imgSz,XSet(indmin(1))')
  46. %xlabel(int2str(XLab(indmin(kk))));
  47. %title('Match Image')
  48. %end
  49. NErrors=Ntests-sum(XLab(indmin)==YLab(1:length(indmin)));
  50. Performances=100-NErrors/Ntests*100