1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- %% Reading Pictures and Labels Sets
- % The function reads Pictures and Labels related to the pictures
- % from binary files in uint8 (unsigned int 8bits) format.
- % It provides also the possibility to Display the read pictures
- % in ordered arrangement, one for each diferent Label.
- %
- % Inputs:
- % - imgSz Size of the single squared picture
- % - N Total Number of pictures
- % - fileOffsetPic Offset for files containing pictures
- % - fileNamePic Name of the binary file containing pictures
- % - fileOffsetLab Offset for files containing labels
- % - fileNameLab Name of the binary file containing labels
- % - Display Flag for the visualization of the read pictures
- %
- % Outputs:
- % - XSet Vector containing the acquired pictures
- % - XLab Vector containing the acquired labels
- %
- % Dependencies:
- % - Xmat = Vector2Matrix(imgSz, N, XSet);
- %
- %%
- function [XSet, XLab]=ReadingPicSetLabSet(imgSz, N, fileOffsetPic, fileNamePic, fileOffsetLab, fileNameLab, Display)
- % Reading Binary Training Images
- fileIDPic = fopen(fileNamePic);
- XSet = fread(fileIDPic,imgSz^2*N+fileOffsetPic,'uint8');
- %XSet = uint8(XSet(fileOffsetPic+1:end));
- XSet = XSet(fileOffsetPic+1:end);
- fclose(fileIDPic);
- % Reading Binary Training Labels
- fileIDLab = fopen(fileNameLab);
- XLab = fread(fileIDLab,N+fileOffsetLab,'uint8');
- %XLab = uint8(XLab(fileOffsetLab+1:end));
- XLab = XLab(fileOffsetLab+1:end);
- fclose(fileIDLab);
- if(Display)
- % Building 3D matrix with N images
- Xmat = Vector2PictureMatrix(imgSz, N, XSet);
- % Showing images
- figure()
- suptitle('Ordered chosen pictures from the Training Data Set')
- for kk=1:10
- subplot(2, 5, kk)
- ind=find(XLab==kk-1,1,'first');
- imshow(255-Xmat(:,:,ind),[0 255])
- xlabel(int2str(XLab(ind)));
- end
- end
- end
|