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/TOOLBOX_calib/saveppm.m | |
parent | 47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff) |
initial sd-vbs
initial sd-vbs
add sd-vbs
sd-vbs
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/saveppm.m')
-rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/saveppm.m | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/saveppm.m b/SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/saveppm.m new file mode 100755 index 0000000..ece092b --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/saveppm.m | |||
@@ -0,0 +1,45 @@ | |||
1 | %SAVEPPM Write a PPM format file | ||
2 | % | ||
3 | % SAVEPPM(filename, I) | ||
4 | % | ||
5 | % Saves the specified red, green and blue planes in a binary (P6) | ||
6 | % format PPM image file. | ||
7 | % | ||
8 | % SEE ALSO: loadppm | ||
9 | % | ||
10 | % Copyright (c) Peter Corke, 1999 Machine Vision Toolbox for Matlab | ||
11 | |||
12 | |||
13 | % Peter Corke 1994 | ||
14 | |||
15 | function saveppm(fname, I) | ||
16 | |||
17 | I = double(I); | ||
18 | |||
19 | if size(I,3) == 1, | ||
20 | R = I; | ||
21 | G = I; | ||
22 | B = I; | ||
23 | else | ||
24 | R = I(:,:,1); | ||
25 | G = I(:,:,2); | ||
26 | B = I(:,:,3); | ||
27 | end; | ||
28 | |||
29 | %keyboard; | ||
30 | |||
31 | fid = fopen(fname, 'w'); | ||
32 | [r,c] = size(R'); | ||
33 | fprintf(fid, 'P6\n'); | ||
34 | fprintf(fid, '%d %d\n', r, c); | ||
35 | fprintf(fid, '255\n'); | ||
36 | R = R'; | ||
37 | G = G'; | ||
38 | B = B'; | ||
39 | im = [R(:) G(:) B(:)]; | ||
40 | %im = reshape(im,r,c*3); | ||
41 | im = im'; | ||
42 | %im = im(:); | ||
43 | fwrite(fid, im, 'uchar'); | ||
44 | fclose(fid); | ||
45 | |||