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/imread2.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/imread2.m')
| -rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/io/imread2.m | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/toolbox_basic/io/imread2.m b/SD-VBS/common/toolbox/toolbox_basic/io/imread2.m new file mode 100755 index 0000000..27a5e4b --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/io/imread2.m | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | function I = imread2(fname,im_dir); | ||
| 2 | % | ||
| 3 | % I = imread2(fname,im_dir); | ||
| 4 | % | ||
| 5 | |||
| 6 | cur_dir = pwd; | ||
| 7 | |||
| 8 | if nargin>1, | ||
| 9 | cd(im_dir); | ||
| 10 | end | ||
| 11 | |||
| 12 | %%% put on the necessary extension | ||
| 13 | d = dir(fname); | ||
| 14 | |||
| 15 | if isempty(d), | ||
| 16 | d = dir([fname,'*']); | ||
| 17 | end | ||
| 18 | |||
| 19 | if isempty(d), | ||
| 20 | I = []; | ||
| 21 | else | ||
| 22 | |||
| 23 | fname = d.name; | ||
| 24 | |||
| 25 | %%% find extension | ||
| 26 | k = findstr(fname,'.'); | ||
| 27 | ext = fname(k(end)+1:end); | ||
| 28 | |||
| 29 | if (ext == 'bz2'), | ||
| 30 | cm = sprintf('!bzip2 -d %s',fname); | ||
| 31 | disp(cm);eval(cm); | ||
| 32 | I = imread2(fname(1:k(end-1)-1)); | ||
| 33 | cm = sprintf('!bzip2 %s',fname(1:k(end)-1)); | ||
| 34 | disp(cm);eval(cm); | ||
| 35 | elseif (ext == 'ppm'); | ||
| 36 | I = readppm(fname); | ||
| 37 | elseif (ext == 'pgm'); | ||
| 38 | I = readpgm(fname); | ||
| 39 | else | ||
| 40 | I = imread(fname); | ||
| 41 | I = double(I)/255; | ||
| 42 | end | ||
| 43 | end | ||
| 44 | |||
| 45 | cd(cur_dir); | ||
