summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/saveppm.m
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/saveppm.m')
-rwxr-xr-xSD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/saveppm.m45
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
15function saveppm(fname, I)
16
17I = double(I);
18
19if size(I,3) == 1,
20 R = I;
21 G = I;
22 B = I;
23else
24 R = I(:,:,1);
25 G = I(:,:,2);
26 B = I(:,:,3);
27end;
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