diff options
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/stella/getimage2.m')
-rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/stella/getimage2.m | 46 |
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 | |||
7 | function f = getimage2(imagefile) | ||
8 | |||
9 | if exist(imagefile)==2, | ||
10 | g = {imagefile}; | ||
11 | else | ||
12 | g = {}; | ||
13 | end | ||
14 | globalenvar; | ||
15 | g = [g; getfnames(IMAGE_DIR,[imagefile,'.*'])]; | ||
16 | |||
17 | j = 1; | ||
18 | for 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 | ||
32 | end | ||
33 | if j, | ||
34 | f = []; | ||
35 | disp('Image not found'); | ||
36 | return; | ||
37 | end | ||
38 | |||
39 | if size(f,3)>1, | ||
40 | %f = sum(f,3)./3; | ||
41 | f = rgb2ntsc(f); | ||
42 | f = f(:,:,1); | ||
43 | end | ||
44 | minf = min(f(:)); | ||
45 | maxf = max(f(:)); | ||
46 | f = (f - minf) ./ (maxf - minf); | ||