-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsukuba_hands.m
More file actions
57 lines (45 loc) · 2.06 KB
/
tsukuba_hands.m
File metadata and controls
57 lines (45 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
% clear;
% load('TsukubaHandSize24x24.mat');
% [w, h, numImgPerview, numViews, numClasses, numSubjects] = size(data);
% % combine wxh and also cobine numImgPerview and numViews
% data = reshape(data, [w, h, numImgPerview*numViews, numClasses, numSubjects]);
% % permute numSubjects and numClasses
% data = permute(data, [1, 2, 3, 5, 4]);
% %reshape
% data = reshape(data, [w, h, size(data, 3) * numSubjects, numClasses]);
% data = orzReshape(data, 1);
% numSamples = size(data, 2); % Number of samples, 4200 in your case
% % Generate a random permutation of indices for your samples
% shuffledIndices = randperm(numSamples);
% % Initialize a matrix to hold the shuffled data
% shuffledData = zeros(size(data));
% % Shuffle the samples
% for classIndex = 1:size(data, 3) % Loop over each class
% shuffledData(:, :, classIndex) = data(:, shuffledIndices, classIndex);
% end
% % Now 'shuffledData' contains your data with samples shuffled randomly
% trainData = uint8(shuffledData);
% imageSize = 24;
% data = reshape(trainData, imageSize, imageSize, size(trainData, 2), size(trainData, 3));
% figure; % Create a new figure window
% for i = 1:30 % Loop through each of the 10 classes
% % random integer, used to display random image
% idx = randi([1, 400]);
% img = squeeze(data(:,:,1,i)); % Extract the first 16x16 image of the i-th class
% subplot(6, 5, i); % Arrange the plots in a 2x5 grid
% imagesc(img); % Display the image
% axis square; % Make each subplot square in shape
% colormap gray; % Use grayscale colors
% title(sprintf('Class %d', i)); % Title each subplot with its class number
% end
%% save shuffled data
% shuffledData = uint8(shuffledData);
% save('shuffleData.mat', 'shuffledData');
% split shuffledData into train and test data
clear;
load('shuffleData.mat');
% shuffledData = shuffledData(:, 1:7200, :);
numTrainingSamples = round(size(shuffledData, 2) * 0.8);
trainData = uint8(shuffledData(:, 1:numTrainingSamples, :));
testData = uint8(shuffledData(:, numTrainingSamples+1:end, :));
save('tsukubaHand24x24.mat', 'trainData', 'testData');