From d17b33131c14864bd1eae275f49a3f148e21cf29 Mon Sep 17 00:00:00 2001 From: Leo Chan Date: Thu, 22 Oct 2020 01:53:21 -0400 Subject: 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. --- SD-VBS/common/toolbox/toolbox_basic/io/read_scan.m | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 SD-VBS/common/toolbox/toolbox_basic/io/read_scan.m (limited to 'SD-VBS/common/toolbox/toolbox_basic/io/read_scan.m') diff --git a/SD-VBS/common/toolbox/toolbox_basic/io/read_scan.m b/SD-VBS/common/toolbox/toolbox_basic/io/read_scan.m new file mode 100755 index 0000000..6ad818a --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/io/read_scan.m @@ -0,0 +1,42 @@ +function [img,sizeinfo] = pgmread(filename) +% function img = pgmread(filename) +% this is my version of pgmread for the pgm file created by XV. +% +% this program also corrects for the shifts in the image from pm file. + + +fname_header = sprintf('%s.h01',filename); +fname_data = sprintf('%s.i01',filename); + +fid = fopen(fname_header,'r'); + + +done = 0; +while done~=3, + cmt = fgets(fid) + if (findstr(cmt,'!matrix size[1]')), + nc = sscanf(cmt,'!matrix size[1] :=%d'); + done = done+1; + elseif (findstr(cmt,'!matrix size[2]')), + nr = sscanf(cmt,'!matrix size[2] :=%d'); + done = done+1; + elseif (findstr(cmt,'!matrix size[3]')), + ns = sscanf(cmt,'!matrix size[3] :=%d'); + done = done+1; + end +end +fclose(fid); + +fid = fopen(fname_data,'r'); + +%img = fscanf(fid,'%d',size); +%img = img'; + +img = fread(fid,nc*nr*ns,'uint8'); +img = reshape(img,nc,nr,ns); + +sizeinfo(1) = nr; +sizeinfo(2) = nc; +sizeinfo(3) = ns; + +fclose(fid); -- cgit v1.2.2