diff options
author | leochanj105 <leochanj@live.unc.edu> | 2020-10-19 23:09:30 -0400 |
---|---|---|
committer | leochanj105 <leochanj@live.unc.edu> | 2020-10-20 02:40:39 -0400 |
commit | f618466c25d43f3bae9e40920273bf77de1e1149 (patch) | |
tree | 460e739e2165b8a9c37a9c7ab1b60f5874903543 /SD-VBS/common/toolbox/toolbox_basic/io/readppm.m | |
parent | 47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff) |
initial sd-vbs
initial sd-vbs
add sd-vbs
sd-vbs
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/io/readppm.m')
-rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/io/readppm.m | 23 |
1 files changed, 23 insertions, 0 deletions
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 @@ | |||
1 | function [I,r, g, b] = readppm(name) | ||
2 | |||
3 | fid = fopen(name, 'r'); | ||
4 | fscanf(fid, 'P6\n'); | ||
5 | cmt = '#'; | ||
6 | while findstr(cmt, '#'), | ||
7 | cmt = fgets(fid); | ||
8 | if length(findstr(cmt, '#')) ~= 1 | ||
9 | YX = sscanf(cmt, '%d %d'); | ||
10 | y = YX(1); x = YX(2); | ||
11 | end | ||
12 | end | ||
13 | fgets(fid); | ||
14 | packed = fread(fid,[3*y,x],'uint8')'; | ||
15 | r = packed(:,1:3:3*y); | ||
16 | g = packed(:,2:3:3*y); | ||
17 | b = packed(:,3:3:3*y); | ||
18 | fclose(fid); | ||
19 | |||
20 | I(:,:,1) = r; | ||
21 | I(:,:,2) = g; | ||
22 | I(:,:,3) = b; | ||
23 | I = I/255; | ||