diff options
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/loadinr.m')
-rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/loadinr.m | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/loadinr.m b/SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/loadinr.m new file mode 100755 index 0000000..91b6f89 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/loadinr.m | |||
@@ -0,0 +1,52 @@ | |||
1 | %LOADINR Load an INRIMAGE format file | ||
2 | % | ||
3 | % LOADINR(filename, im) | ||
4 | % | ||
5 | % Load an INRIA image format file and return it as a matrix | ||
6 | % | ||
7 | % SEE ALSO: saveinr | ||
8 | % | ||
9 | % Copyright (c) Peter Corke, 1999 Machine Vision Toolbox for Matlab | ||
10 | |||
11 | |||
12 | % Peter Corke 1996 | ||
13 | |||
14 | function im = loadinr(fname, im) | ||
15 | |||
16 | fid = fopen(fname, 'r'); | ||
17 | |||
18 | s = fgets(fid); | ||
19 | if strcmp(s(1:12), '#INRIMAGE-4#') == 0, | ||
20 | error('not INRIMAGE format'); | ||
21 | end | ||
22 | |||
23 | % not very complete, only looks for the X/YDIM keys | ||
24 | while 1, | ||
25 | s = fgets(fid); | ||
26 | n = length(s) - 1; | ||
27 | if s(1) == '#', | ||
28 | break | ||
29 | end | ||
30 | if strcmp(s(1:5), 'XDIM='), | ||
31 | cols = str2num(s(6:n)); | ||
32 | end | ||
33 | if strcmp(s(1:5), 'YDIM='), | ||
34 | rows = str2num(s(6:n)); | ||
35 | end | ||
36 | if strcmp(s(1:4), 'CPU='), | ||
37 | if strcmp(s(5:n), 'sun') == 0, | ||
38 | error('not sun data ordering'); | ||
39 | end | ||
40 | end | ||
41 | |||
42 | end | ||
43 | disp(['INRIMAGE format file ' num2str(rows) ' x ' num2str(cols)]) | ||
44 | |||
45 | % now the binary data | ||
46 | fseek(fid, 256, 'bof'); | ||
47 | [im count] = fread(fid, [cols rows], 'float32'); | ||
48 | im = im'; | ||
49 | if count ~= (rows*cols), | ||
50 | error('file too short'); | ||
51 | end | ||
52 | fclose(fid); | ||