Home > src > matlab > pfs_read_luminance.m

pfs_read_luminance

PURPOSE ^

PFS_READ_LUMINANCE read image file and return luminance channel Y.

SYNOPSIS ^

function Y = pfs_read_luminance( fileName )

DESCRIPTION ^

PFS_READ_LUMINANCE read image file and return luminance channel Y.

  Y = PFS_READ_LUMINANCE( file_name )

 PFS_READ_LUMINANCE 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 Y = pfs_read_luminance( fileName )
0002 %PFS_READ_LUMINANCE read image file and return luminance channel Y.
0003 %
0004 %  Y = PFS_READ_LUMINANCE( file_name )
0005 %
0006 % PFS_READ_LUMINANCE accepts all formats recognized by the shell "pfsin"
0007 % command.
0008 %
0009 % See also: PFS_READ_IMAGE, PFS_READ_LUMINANCE, PFS_READ_XYZ, PFS_WRITE_IMAGE.
0010 %
0011 % Copyright 2009 Rafal Mantiuk
0012 
0013   % Check if file exists
0014   fid = fopen( fileName, 'r' );
0015   if( fid == -1 ) 
0016     error( 'pfs_read_luminance: File "%s" does not exist', fileName );
0017   end
0018   fclose( fid );
0019      
0020 %  try
0021     cmd = sprintf( '%spfsin ''%s''%s', pfs_shell(), fileName, pfs_shell( 1 ) );
0022     fid = pfspopen( cmd, 'r' );
0023     pin = pfsopen( fid );
0024     pin = pfsget( pin );
0025     Y = pin.channels.Y;  
0026     pfsclose( pin );
0027     % TODO: Check why crashes on windows
0028     if ~ispc()
0029         pfspclose( fid );
0030     end
0031 %  catch
0032  %   pfsclose( pin );
0033  %   pfspclose( fid );
0034 %  end
0035 
0036 end

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