summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/toolbox_basic/calib_bouguetj/savepgm.m
blob: 397f0286d24edf91dfeae72a6d2b87a4cf5396f2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
%SAVEPGM	Write a PGM format file
%
%	SAVEPGM(filename, im)
%
%	Saves the specified image array in a binary (P5) format PGM image file.
% 
% SEE ALSO:	loadpgm
%
%	Copyright (c) Peter Corke, 1999  Machine Vision Toolbox for Matlab


% Peter Corke 1994

function savepgm(fname, im)

	fid = fopen(fname, 'w');
	[r,c] = size(im');
	fprintf(fid, 'P5\n');
	fprintf(fid, '%d %d\n', r, c);
	fprintf(fid, '255\n');
	fwrite(fid, im', 'uchar');
	fclose(fid)