summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/toolbox_basic/io/imread2.m
diff options
context:
space:
mode:
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);