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/readppm.m | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 SD-VBS/common/toolbox/toolbox_basic/io/readppm.m (limited to 'SD-VBS/common/toolbox/toolbox_basic/io/readppm.m') diff --git a/SD-VBS/common/toolbox/toolbox_basic/io/readppm.m b/SD-VBS/common/toolbox/toolbox_basic/io/readppm.m new file mode 100755 index 0000000..b9dd566 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/io/readppm.m @@ -0,0 +1,23 @@ +function [I,r, g, b] = readppm(name) + + fid = fopen(name, 'r'); + fscanf(fid, 'P6\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); + packed = fread(fid,[3*y,x],'uint8')'; + r = packed(:,1:3:3*y); + g = packed(:,2:3:3*y); + b = packed(:,3:3:3*y); + fclose(fid); + + I(:,:,1) = r; + I(:,:,2) = g; + I(:,:,3) = b; + I = I/255; -- cgit v1.2.2