-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwriteDBL.m
More file actions
33 lines (22 loc) · 768 Bytes
/
writeDBL.m
File metadata and controls
33 lines (22 loc) · 768 Bytes
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
function writeDBL(image, savepath)
% write data into a .dbl file in Matlab
%
% pixel lengths as unsigned 16 bit with Big-Endian
% Physical lengths as X with Little-Endian
% 104 8-bit unsigned ints with Big-Endian
% Image as Single with Little-Endian
%
% originally copied from Edward Allgeyer
% revised by Xiang Hao on Sep. 20, 2015. Now also compatible with 2D data
imsize = size(image);
if length(imsize) == 2
imsize=[imsize(1),imsize(2),1];
end
fid = fopen(savepath, 'w');
fwrite(fid, [1, imsize], 'uint16', 'b');
fwrite(fid, [1, 1, 1, 1], 'single', 'l');
holder(1:104) = 1;
fwrite(fid, holder, 'uint8', 'b');
image = reshape(image, [imsize(1)*imsize(2)*imsize(3), 1]);
fwrite(fid, image, 'single', 'l');
fclose(fid);