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/io/read_scan.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/io/read_scan.m')
| -rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/io/read_scan.m | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/toolbox_basic/io/read_scan.m b/SD-VBS/common/toolbox/toolbox_basic/io/read_scan.m new file mode 100755 index 0000000..6ad818a --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/io/read_scan.m | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | function [img,sizeinfo] = pgmread(filename) | ||
| 2 | % function img = pgmread(filename) | ||
| 3 | % this is my version of pgmread for the pgm file created by XV. | ||
| 4 | % | ||
| 5 | % this program also corrects for the shifts in the image from pm file. | ||
| 6 | |||
| 7 | |||
| 8 | fname_header = sprintf('%s.h01',filename); | ||
| 9 | fname_data = sprintf('%s.i01',filename); | ||
| 10 | |||
| 11 | fid = fopen(fname_header,'r'); | ||
| 12 | |||
| 13 | |||
| 14 | done = 0; | ||
| 15 | while done~=3, | ||
| 16 | cmt = fgets(fid) | ||
| 17 | if (findstr(cmt,'!matrix size[1]')), | ||
| 18 | nc = sscanf(cmt,'!matrix size[1] :=%d'); | ||
| 19 | done = done+1; | ||
| 20 | elseif (findstr(cmt,'!matrix size[2]')), | ||
| 21 | nr = sscanf(cmt,'!matrix size[2] :=%d'); | ||
| 22 | done = done+1; | ||
| 23 | elseif (findstr(cmt,'!matrix size[3]')), | ||
| 24 | ns = sscanf(cmt,'!matrix size[3] :=%d'); | ||
| 25 | done = done+1; | ||
| 26 | end | ||
| 27 | end | ||
| 28 | fclose(fid); | ||
| 29 | |||
| 30 | fid = fopen(fname_data,'r'); | ||
| 31 | |||
| 32 | %img = fscanf(fid,'%d',size); | ||
| 33 | %img = img'; | ||
| 34 | |||
| 35 | img = fread(fid,nc*nr*ns,'uint8'); | ||
| 36 | img = reshape(img,nc,nr,ns); | ||
| 37 | |||
| 38 | sizeinfo(1) = nr; | ||
| 39 | sizeinfo(2) = nc; | ||
| 40 | sizeinfo(3) = ns; | ||
| 41 | |||
| 42 | fclose(fid); | ||
