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