diff options
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/saveinr.m')
-rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/saveinr.m | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/saveinr.m b/SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/saveinr.m new file mode 100755 index 0000000..a176e39 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/saveinr.m | |||
@@ -0,0 +1,46 @@ | |||
1 | %SAVEINR Write an INRIMAGE format file | ||
2 | % | ||
3 | % SAVEINR(filename, im) | ||
4 | % | ||
5 | % Saves the specified image array in a INRIA image format file. | ||
6 | % | ||
7 | % SEE ALSO: loadinr | ||
8 | % | ||
9 | % Copyright (c) Peter Corke, 1999 Machine Vision Toolbox for Matlab | ||
10 | |||
11 | % Peter Corke 1996 | ||
12 | |||
13 | function saveinr(fname, im) | ||
14 | |||
15 | fid = fopen(fname, 'w'); | ||
16 | [r,c] = size(im'); | ||
17 | |||
18 | % build the header | ||
19 | hdr = []; | ||
20 | s = sprintf('#INRIMAGE-4#{\n'); | ||
21 | hdr = [hdr s]; | ||
22 | s = sprintf('XDIM=%d\n',c); | ||
23 | hdr = [hdr s]; | ||
24 | s = sprintf('YDIM=%d\n',r); | ||
25 | hdr = [hdr s]; | ||
26 | s = sprintf('ZDIM=1\n'); | ||
27 | hdr = [hdr s]; | ||
28 | s = sprintf('VDIM=1\n'); | ||
29 | hdr = [hdr s]; | ||
30 | s = sprintf('TYPE=float\n'); | ||
31 | hdr = [hdr s]; | ||
32 | s = sprintf('PIXSIZE=32\n'); | ||
33 | hdr = [hdr s]; | ||
34 | s = sprintf('SCALE=2**0\n'); | ||
35 | hdr = [hdr s]; | ||
36 | s = sprintf('CPU=sun\n#'); | ||
37 | hdr = [hdr s]; | ||
38 | |||
39 | % make it 256 bytes long and write it | ||
40 | hdr256 = zeros(1,256); | ||
41 | hdr256(1:length(hdr)) = hdr; | ||
42 | fwrite(fid, hdr256, 'uchar'); | ||
43 | |||
44 | % now the binary data | ||
45 | fwrite(fid, im', 'float32'); | ||
46 | fclose(fid) | ||