0001 function pfsview( varargin )
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 width = -1;
0018 height = -1;
0019
0020 title = 'matlab';
0021 n = 1;
0022 for i=1:length( varargin )
0023 if iscell(varargin{i})
0024 C = varargin{i};
0025 width = size( C{1}, 2 );
0026 height = size( C{1}, 1 );
0027 if( size( C, 1 ) > 1 )
0028 for j=1:size(C,1)
0029 for k=1:size(C,2)
0030 if( any( size(C{j,k}) ~= [height width] ) )
0031 continue;
0032 end
0033 ch_name = sprintf( 'c_%d_%dx%d', n, j, k );
0034 channels.(ch_name) = C{j, k};
0035 end
0036 end
0037 else
0038 for j=1:length(C)
0039 ch_name = sprintf( 'cell_%d_%d', n, j );
0040 channels.(ch_name) = C{j};
0041 end
0042 end
0043 n = n+1;
0044 elseif( isnumeric( varargin{i} ) )
0045 m_size = size( varargin{i} );
0046 width = m_size(2);
0047 height = m_size(1);
0048 if( length(m_size) == 2 )
0049 matrix_name = inputname( i );
0050 if( isempty( matrix_name ) )
0051 ch_name = sprintf( 'matrix_%d', n );
0052 else
0053 ch_name = matrix_name;
0054 end
0055 n = n+1;
0056 channels.( ch_name ) = single( varargin{i} );
0057 elseif( length(m_size) == 3 && m_size(3)==3 )
0058
0059 [channels.X channels.Y channels.Z] = pfs_transform_colorspace( 'RGB', single(varargin{i}), 'XYZ' );
0060 else
0061 error( [ 'Cannot display matrix of the size [' num2str( m_size ) ']' ] );
0062 end
0063 elseif( islogical( varargin{i} ) )
0064 ch_name = sprintf( 'bool_%d', n );
0065 n = n+1;
0066 channels.(ch_name) = double(varargin{i});
0067 m_size = size( varargin{i} );
0068 width = m_size(2);
0069 height = m_size(1);
0070 elseif( ischar( varargin{i} ) )
0071 if( i == 1 )
0072 title = varargin{i};
0073 else
0074 if( ~exist( 'channels', 'var' ) || ~exist( 'ch_name', 'var' ) )
0075 error( 'channel_name argument must follow channel argument' );
0076 else
0077 channels.(varargin{i}) = channels.( ch_name );
0078 channels = rmfield( channels, ch_name );
0079 clear ch_name;
0080 end
0081 end
0082 end
0083 end
0084
0085
0086
0087 tmp_file = tempname();
0088 pfsout = pfsopen( tmp_file, height, width );
0089 pfsout.channels = channels;
0090 pfsout.tags.FILE_NAME = title;
0091 pfsput( pfsout );
0092 pfsclose( pfsout );
0093
0094 system( sprintf( '%s(pfsview <''%s'' && rm -f %s) &%s', pfs_shell(), tmp_file, tmp_file, pfs_shell( 1 ) ) );
0095
0096 end