From f618466c25d43f3bae9e40920273bf77de1e1149 Mon Sep 17 00:00:00 2001 From: leochanj105 Date: Mon, 19 Oct 2020 23:09:30 -0400 Subject: initial sd-vbs initial sd-vbs add sd-vbs sd-vbs --- .../toolbox/toolbox_basic/stella/getimage2.m | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 SD-VBS/common/toolbox/toolbox_basic/stella/getimage2.m (limited to 'SD-VBS/common/toolbox/toolbox_basic/stella/getimage2.m') 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 @@ +% function f = getimage2(imagefile) returns a normalized intensity image. +% If the file postfix is not given, then I will search any possible image file +% under the IMAGE_DIR. + +% Stella X. Yu, March 1999 + +function f = getimage2(imagefile) + +if exist(imagefile)==2, + g = {imagefile}; +else + g = {}; +end +globalenvar; +g = [g; getfnames(IMAGE_DIR,[imagefile,'.*'])]; + +j = 1; +for i=1:length(g), + k = findstr(g{i},'.'); + gp = g{i}(k(end)+1:end); + if strcmp(gp,'ppm'), + f = double(readppm(g{i})); + j = 0; + elseif sum(strcmp(gp,{'jpg','tif','jpeg','tiff','bmp','png','hdf','pcx','xwd'}))>0, + f = double(imread(g{i})); + j = 0; + end + if j==0, + disp(sprintf('This is an image read from %s under %s',g{i},IMAGE_DIR)); + break; + end +end +if j, + f = []; + disp('Image not found'); + return; +end + +if size(f,3)>1, + %f = sum(f,3)./3; + f = rgb2ntsc(f); + f = f(:,:,1); +end +minf = min(f(:)); +maxf = max(f(:)); +f = (f - minf) ./ (maxf - minf); -- cgit v1.2.2