Home > src > matlab > pfs_read_xyz.m

pfs_read_xyz

PURPOSE ^

PFS_READ_XYZ read image file and return X, Y, and Z color channels.

SYNOPSIS ^

function varargout = pfs_read_xyz( fileName )

DESCRIPTION ^

PFS_READ_XYZ read image file and return X, Y, and Z color channels.

 [X Y Z] = PFS_READ_XYZ( file_name )
 IMG = PFS_READ_XYZ( file_name )

 PFS_READ_XYZ accepts all formats recognized by the shell "pfsin"
 command.

 See also: PFS_READ_IMAGE, PFS_READ_LUMINANCE, PFS_READ_XYZ, PFS_WRITE_IMAGE.

 Copyright 2009 Rafal Mantiuk

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = pfs_read_xyz( fileName )
0002 %PFS_READ_XYZ read image file and return X, Y, and Z color channels.
0003 %
0004 % [X Y Z] = PFS_READ_XYZ( file_name )
0005 % IMG = PFS_READ_XYZ( file_name )
0006 %
0007 % PFS_READ_XYZ accepts all formats recognized by the shell "pfsin"
0008 % command.
0009 %
0010 % See also: PFS_READ_IMAGE, PFS_READ_LUMINANCE, PFS_READ_XYZ, PFS_WRITE_IMAGE.
0011 %
0012 % Copyright 2009 Rafal Mantiuk
0013   
0014   % Check if file exists
0015   fid = fopen( fileName, 'rb' );
0016   if( fid == -1 ) 
0017     error( 'pfs_read_xyz: File "%s" does not exist', fileName );
0018   end
0019   fclose( fid );
0020 
0021   fid = pfspopen( sprintf( '%spfsin ''%s''%s', pfs_shell(), fileName, pfs_shell( 1 ) ), 'r' );
0022   pin = pfsopen( fid );
0023   pin = pfsget( pin );
0024   pfsclose( pin );
0025   pfspclose( fid );
0026   
0027   if( nargout == 3 )
0028       varargout{1} = pin.channels.X;
0029       varargout{2} = pin.channels.Y;
0030       varargout{3} = pin.channels.Z;      
0031   elseif( nargout == 1 )
0032       varargout{1} = cat( 3, pin.channels.X, pin.channels.Y, pin.channels.Z );
0033   else
0034       error( 'Wrong number of output parameters' );
0035   end
0036     
0037 end
0038

Generated on Tue 03-Mar-2009 13:03:09 by m2html © 2003