You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.2 KiB
Matlab
38 lines
1.2 KiB
Matlab
function [images,classes,numClasses]=load_data_norb(trainortest)
|
|
if trainortest==1
|
|
numImages=2000 %24300 max
|
|
datafile='../Data/SmallNORB/smallnorb-5x46789x9x18x6x2x96x96-training-dat.mat';
|
|
catfile='../Data/SmallNORB/smallnorb-5x46789x9x18x6x2x96x96-training-cat.mat';
|
|
else
|
|
numImages=200 %24300 max
|
|
datafile='../Data/SmallNORB/smallnorb-5x01235x9x18x6x2x96x96-testing-dat.mat';
|
|
catfile='../Data/SmallNORB/smallnorb-5x01235x9x18x6x2x96x96-testing-cat.mat';
|
|
end
|
|
[images,classes]=read_norb_data(datafile,catfile,numImages);
|
|
classes=classes+1; %make smallest class number equal to 1
|
|
numClasses=max(classes);
|
|
|
|
|
|
function [data,class]=read_norb_data(datafile,catfile,numPatterns)
|
|
fid=fopen(catfile,'r');
|
|
for p=1:5 %read header information - and ignore it
|
|
fread(fid,4,'uchar');
|
|
end
|
|
class=fread(fid,numPatterns,'int')';
|
|
fclose(fid);
|
|
|
|
fid=fopen(datafile,'r');
|
|
for p=1:6 %read header information - and ignore it
|
|
fread(fid,4,'uchar');
|
|
end
|
|
data=zeros(96*96,numPatterns);
|
|
for i=1:numPatterns
|
|
for j=1:2 %take one image in each pair
|
|
I=fread(fid,96*96);
|
|
end
|
|
%I=I-min(I);I=I./max(I);
|
|
data(:,i)=I./255;%make intensity values vary from 0 to 1
|
|
end
|
|
fclose(fid);
|
|
data=data';
|