summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/toolbox_basic/io/imread2.m
diff options
context:
space:
mode:
authorLeo Chan <leochanj@live.unc.edu>2020-10-22 01:53:21 -0400
committerJoshua Bakita <jbakita@cs.unc.edu>2020-10-22 01:56:35 -0400
commitd17b33131c14864bd1eae275f49a3f148e21cf29 (patch)
tree0d8f77922e8d193cb0f6edab83018f057aad64a0 /SD-VBS/common/toolbox/toolbox_basic/io/imread2.m
parent601ed25a4c5b66cb75315832c15613a727db2c26 (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-xSD-VBS/common/toolbox/toolbox_basic/io/imread2.m45
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 @@
1function I = imread2(fname,im_dir);
2%
3% I = imread2(fname,im_dir);
4%
5
6cur_dir = pwd;
7
8if nargin>1,
9 cd(im_dir);
10end
11
12%%% put on the necessary extension
13d = dir(fname);
14
15if isempty(d),
16 d = dir([fname,'*']);
17end
18
19if isempty(d),
20 I = [];
21else
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);
41I = double(I)/255;
42 end
43end
44
45cd(cur_dir);