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 --- SD-VBS/common/toolbox/toolbox_basic/io/pgmread.m | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 SD-VBS/common/toolbox/toolbox_basic/io/pgmread.m (limited to 'SD-VBS/common/toolbox/toolbox_basic/io/pgmread.m') diff --git a/SD-VBS/common/toolbox/toolbox_basic/io/pgmread.m b/SD-VBS/common/toolbox/toolbox_basic/io/pgmread.m new file mode 100755 index 0000000..49a35a8 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/io/pgmread.m @@ -0,0 +1,24 @@ +function [img,header] = pgmread(filename) +% +% [img,header] = pgmread(filename) + +[fid, msg] = fopen(filename, 'r'); +if fid == -1, + error(msg) +end + +head = []; +good = 0; +while (good == 0) , + l = fgetl(fid); + if (length(l) == 3), + if (l == '255'), + good = 1; + sze = sscanf(header,'%d'); + end + end + header= l; +end + +img = fread(fid, sze', 'uchar')'; +fclose(fid); -- cgit v1.2.2