summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/toolbox_basic/stella/getimage2.m
diff options
context:
space:
mode:
authorleochanj105 <leochanj@live.unc.edu>2020-10-19 23:09:30 -0400
committerleochanj105 <leochanj@live.unc.edu>2020-10-20 02:40:39 -0400
commitf618466c25d43f3bae9e40920273bf77de1e1149 (patch)
tree460e739e2165b8a9c37a9c7ab1b60f5874903543 /SD-VBS/common/toolbox/toolbox_basic/stella/getimage2.m
parent47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff)
initial sd-vbs
initial sd-vbs add sd-vbs sd-vbs
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);