PFS_WRITE_XYZ write an XYZ image file. PFS_WRITE_XYZ( file_name, X, Y, Z ) PFS_WRITE_XYZ( file_name, img ) X, Y, Z - XYZ color channels, given as linear response img - 3D matrix image, where img(:,:,1:3) represents XYZ color channels The format of the file is recognized based in the file name extension: .hdr for Radiance images, .exr for OpenEXR, .jpg for JPEG and .png for PNG. See manual of "pfsout" shell command for the full list of the supported formats. See also: PFS_WRITE_IMAGE, PFS_WRITE_LUMINANCE, PFS_WRITE_RGB, PFS_READ_IMAGE. Copyright 2009 Rafal Mantiuk
0001 function pfs_write_xyz( fileName, varargin ) 0002 %PFS_WRITE_XYZ write an XYZ image file. 0003 % 0004 % PFS_WRITE_XYZ( file_name, X, Y, Z ) 0005 % PFS_WRITE_XYZ( file_name, img ) 0006 % 0007 % X, Y, Z - XYZ color channels, given as linear response 0008 % img - 3D matrix image, where img(:,:,1:3) represents XYZ color channels 0009 % 0010 % The format of the file is recognized based in the file name extension: 0011 % .hdr for Radiance images, .exr for OpenEXR, .jpg for JPEG and .png for 0012 % PNG. See manual of "pfsout" shell command for the full list of the 0013 % supported formats. 0014 % 0015 % See also: PFS_WRITE_IMAGE, PFS_WRITE_LUMINANCE, PFS_WRITE_RGB, 0016 % PFS_READ_IMAGE. 0017 % 0018 % Copyright 2009 Rafal Mantiuk 0019 0020 %cmd = sprintf( '%spfsout %s%s', pfs_shell(), fileName, pfs_shell(1) ) 0021 fid = pfspopen( sprintf( '%spfsout ''%s''%s', pfs_shell(), fileName, pfs_shell(1) ), 'w' ); 0022 pfs = pfsopen( fid, [size( varargin{1}, 1 ) size( varargin{1}, 2 )] ); 0023 0024 if( nargin == 4 ) 0025 if( ~isnumeric(varargin{1}) || ~isnumeric(varargin{2}) || ~isnumeric(varargin{1}) ) 0026 error( 'pfs_write_xyz: matrices of the equal size expected as an arguments' ); 0027 end 0028 pfs.channels.X = single(varargin{1}); 0029 pfs.channels.Y = single(varargin{2}); 0030 pfs.channels.Z = single(varargin{3}); 0031 elseif( nargin == 2 && ndims(varargin{1}) == 3 ) 0032 pfs.channels.X = single(varargin{1}(:,:,1)); 0033 pfs.channels.Y = single(varargin{1}(:,:,2)); 0034 pfs.channels.Z = single(varargin{1}(:,:,3)); 0035 else 0036 error( 'pfs_write_xyz: improper usage' ); 0037 end 0038 0039 pfsput( pfs ); 0040 pfsclose( pfs ); 0041 pfspclose( fid ); 0042 0043 end