summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/toolbox_basic/stella/getimage2.m
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/stella/getimage2.m')
-rwxr-xr-xSD-VBS/common/toolbox/toolbox_basic/stella/getimage2.m46
1 files changed, 46 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/toolbox_basic/stella/getimage2.m b/SD-VBS/common/toolbox/toolbox_basic/stella/getimage2.m
new file mode 100755
index 0000000..945ddd2
--- /dev/null
+++ b/SD-VBS/common/toolbox/toolbox_basic/stella/getimage2.m
@@ -0,0 +1,46 @@
1% function f = getimage2(imagefile) returns a normalized intensity image.
2% If the file postfix is not given, then I will search any possible image file
3% under the IMAGE_DIR.
4
5% Stella X. Yu, March 1999
6
7function f = getimage2(imagefile)
8
9if exist(imagefile)==2,
10 g = {imagefile};
11else
12 g = {};
13end
14globalenvar;
15g = [g; getfnames(IMAGE_DIR,[imagefile,'.*'])];
16
17j = 1;
18for i=1:length(g),
19 k = findstr(g{i},'.');
20 gp = g{i}(k(end)+1:end);
21 if strcmp(gp,'ppm'),
22 f = double(readppm(g{i}));
23 j = 0;
24 elseif sum(strcmp(gp,{'jpg','tif','jpeg','tiff','bmp','png','hdf','pcx','xwd'}))>0,
25 f = double(imread(g{i}));
26 j = 0;
27 end
28 if j==0,
29 disp(sprintf('This is an image read from %s under %s',g{i},IMAGE_DIR));
30 break;
31 end
32end
33if j,
34 f = [];
35 disp('Image not found');
36 return;
37end
38
39if size(f,3)>1,
40 %f = sum(f,3)./3;
41 f = rgb2ntsc(f);
42 f = f(:,:,1);
43end
44minf = min(f(:));
45maxf = max(f(:));
46f = (f - minf) ./ (maxf - minf);