diff options
author | Leo Chan <leochanj@live.unc.edu> | 2020-10-22 01:53:21 -0400 |
---|---|---|
committer | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-22 01:56:35 -0400 |
commit | d17b33131c14864bd1eae275f49a3f148e21cf29 (patch) | |
tree | 0d8f77922e8d193cb0f6edab83018f057aad64a0 /SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/loadinr.m | |
parent | 601ed25a4c5b66cb75315832c15613a727db2c26 (diff) |
Squashed commit of the sb-vbs branch.
Includes the SD-VBS benchmarks modified to:
- Use libextra to loop as realtime jobs
- Preallocate memory before starting their main computation
- Accept input via stdin instead of via argc
Does not include the SD-VBS matlab code.
Fixes libextra execution in LITMUS^RT.
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); | ||