ReadingTrainingDataSet.m 865 B

12345678910111213141516171819202122232425262728293031323334353637
  1. clear all
  2. close all
  3. clc
  4. imgSz=28; % square image pixel size
  5. N=6e4; % Number of pictures to label
  6. %% Reading Binary Training Images
  7. fileOffset = 16; % bytes of file offset
  8. fileID = fopen('../Data/train-images.idx3-ubyte');
  9. Xset = fread(fileID,imgSz^2*N+fileOffset,'uint8');
  10. Xset = Xset(fileOffset+1:end);
  11. fclose(fileID);
  12. %% Reading Binary Training Labels
  13. fileOffsetL = 8; % bytes of file offset
  14. fileIDL = fopen('../Data/train-labels.idx1-ubyte');
  15. Xl = fread(fileIDL,N+fileOffsetL,'uint8');
  16. Xl = Xl(fileOffsetL+1:end);
  17. fclose(fileIDL);
  18. %% Building 3D matrix with N images
  19. Xmat = Vector2PictureMatrix(imgSz, N, Xset);
  20. %% Showing images
  21. figure()
  22. suptitle('Ordered chosen pictures from the Testing Data Set')
  23. for kk=1:10
  24. subplot(2, 5, kk)
  25. ind=find(Xl==kk-1,1,'first');
  26. imshow(255-Xmat(:,:,ind),[0 255])
  27. xlabel(int2str(Xl(ind)));
  28. end