diff options
author | Leo Chan <leochanj@live.unc.edu> | 2020-10-22 01:53:21 -0400 |
---|---|---|
committer | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-22 01:56:35 -0400 |
commit | d17b33131c14864bd1eae275f49a3f148e21cf29 (patch) | |
tree | 0d8f77922e8d193cb0f6edab83018f057aad64a0 /SD-VBS/common/toolbox/toolbox_basic/stella/getimage2.m | |
parent | 601ed25a4c5b66cb75315832c15613a727db2c26 (diff) |
Squashed commit of the sb-vbs branch.
Includes the SD-VBS benchmarks modified to:
- Use libextra to loop as realtime jobs
- Preallocate memory before starting their main computation
- Accept input via stdin instead of via argc
Does not include the SD-VBS matlab code.
Fixes libextra execution in LITMUS^RT.
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); | ||