summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/toolbox_basic/calib_bouguetj/saveppm.m
blob: 0062ee014f3946405e7788df98e1c78a1e79d968 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
%SAVEPPM	Write a PPM format file
%
%	SAVEPPM(filename, r, g, b)
%
%	Saves the specified red, green and blue planes in a binary (P6)
%	format PPM image file.
%
% SEE ALSO:	loadppm
%
%	Copyright (c) Peter Corke, 1999  Machine Vision Toolbox for Matlab


% Peter Corke 1994

function saveppm(fname, R, G, B)

	fid = fopen(fname, 'w');
	[r,c] = size(R');
	fprintf(fid, 'P6\n');
	fprintf(fid, '%d %d\n', r, c);
	fprintf(fid, '255\n');
	im = [R(:) G(:) B(:)];
	im = reshape(c,r);
	fwrite(fid, im, 'uchar');
	fclose(fid)