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/readpgm.m | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 SD-VBS/common/toolbox/toolbox_basic/io/readpgm.m (limited to 'SD-VBS/common/toolbox/toolbox_basic/io/readpgm.m') diff --git a/SD-VBS/common/toolbox/toolbox_basic/io/readpgm.m b/SD-VBS/common/toolbox/toolbox_basic/io/readpgm.m new file mode 100755 index 0000000..7aaf998 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/io/readpgm.m @@ -0,0 +1,30 @@ +function img = 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. + + +fid = fopen(filename,'r'); +if (fid < 0), + error(sprintf('can not find file: %s',filename)); +end + +fscanf(fid, 'P5\n'); +cmt = '#'; +while findstr(cmt, '#'), + cmt = fgets(fid); + if length(findstr(cmt, '#')) ~= 1, + YX = sscanf(cmt, '%d %d'); + y = YX(1); x = YX(2); + end +end + +fgets(fid); + +%img = fscanf(fid,'%d',size); +%img = img'; + +img = fread(fid,[y,x],'uint8'); +img = img'; +fclose(fid); -- cgit v1.2.2