forked from kwikteam/npy-matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_readNPY.m
58 lines (38 loc) · 1.27 KB
/
test_readNPY.m
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
%% Test the readNPY function with given data
dtypes = {'uint8','uint16','uint32','uint64','int8','int16','int32','int64','float32','float64'};
figure;
for d = 1:length(dtypes)
data = readNPY(['data/sine_' dtypes{d} '.npy']);
subplot(length(dtypes),1,d)
plot(data)
title(dtypes{d});
end
figure;
for d = 1:length(dtypes)
data = readNPY(['data/chelsea_' dtypes{d} '.npy']);
data(1:3,1:3,:)
subplot(length(dtypes),1,d)
imagesc(double(data)./255)
title(dtypes{d});
end
%% test readNPY and writeNPY
dtypes = {'uint8','uint16','uint32','uint64','int8','int16','int32','int64','float32','float64'};
figure;
for d = 1:length(dtypes)
data = readNPY(['data/sine_' dtypes{d} '.npy']);
writeNPY(data, ['data/matlab_sine_' dtypes{d} '.npy']);
data = readNPY(['data/matlab_sine_' dtypes{d} '.npy']);
subplot(length(dtypes),1,d)
plot(data)
title(dtypes{d});
end
figure;
for d = 1:length(dtypes)
data = readNPY(['data/chelsea_' dtypes{d} '.npy']);
writeNPY(data, ['data/matlab_chelsea_' dtypes{d} '.npy']);
data = readNPY(['data/matlab_chelsea_' dtypes{d} '.npy']);
data(1:3,1:3,:)
subplot(length(dtypes),1,d)
imagesc(double(data)./255)
title(dtypes{d});
end