-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMergeMatrixData.m
More file actions
70 lines (63 loc) · 2 KB
/
MergeMatrixData.m
File metadata and controls
70 lines (63 loc) · 2 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
58
59
60
61
62
63
64
65
66
67
68
69
70
function mergeMatrixData(mergeFolderName, mergeNum)
%% Merge data
% Merge Mat files that structure is [height, width, numPic, numClass]
% Input
% destination path: Merge files output to this folder
% merge path: The folder paths that includes merge data you want
% Output
% Merged data: Merged data
% ex. one folder includes 240x240x500x4 data matrix
% another includes 240x320x800x4 data matrix
% output matrix is 240x320x1300x4
while 1
savePath = input('Input a destination path --> ','s');
if ~isempty(savePath); break; end
end
for i = 1:mergeNum
tmpFolderName = sprintf('%s%d', mergeFolderName, i);
inputStr{i} = tmpFolderName;
oneDir = dir(inputStr{i});
mergeFileNames(:, i) = oneDir(4:end);
end
dataNum = size(mergeFileNames, 1);
classNum = dataNum / 3;
fprintf('start merge data\n');
for i = 1:classNum
fprintf('Loading splited data\n');
for j = 1:mergeNum
path1 = strcat(inputStr{j},'/', mergeFileNames((i-1)*3+2, j).name);
path2 = strcat(inputStr{j},'/', mergeFileNames(i*3, j).name);
tmpData1(j) = load(path1);
tmpData2(j) = load(path2);
end
CDATA = cat(3, tmpData1(:).DATAC);
grayData = cat(3, tmpData2(:).grayData);
fprintf('Merged class %d data\n', i);
depthPath = strcat(savePath, '/', mergeFileNames((i-1)*3+2, 1).name);
grayPath = strcat(savePath, '/', mergeFileNames(i*3, 1).name);
save(depthPath, 'CDATA');
save(grayPath, 'grayData');
fprintf('Saved class %d data\n', i);
end
[height, width, numSet] = size(grayData);
numClass = classNum;
for i = 1:numClass
label{i, 1}=i;
end
%% Create cf.mat
INFO = CvhInfo();
% cf.DefCamH = height;
% cf.DefCamW = width;
% cf.DefNumClass = 0;
% cf.DefNumTimes = 0;
% cf.DefRegion = [1, 1, width, height];
INFO.nSubj = 1;
INFO.nClass = numClass;
INFO.nSet = numSet;
INFO.nW = width;
INFO.nH = height;
INFO.rc = [1, 1, width, height];
INFO.isExtracted = [];
INFO.isTrained = 0;
INFO.LB = label;
save(strcat(savePath, '/INFO.mat'), 'INFO');