Home > vbmeg > functions > device > vivid > vb_get_vivid_proj.m

vb_get_vivid_proj

PURPOSE ^

Project SPM-R coordinate to 2D screen

SYNOPSIS ^

function [V,F,C,X,Y,Z] = vb_get_vivid_proj(Coord, LR)

DESCRIPTION ^

 Project SPM-R coordinate to 2D screen
  [V,F,C,X,Y,Z] = vb_get_vivid_proj(Coord, LR)
 --- Input
 Coord : Left / Right /Front  head coordinate
  'MGF'- File
        .LV   / .RV   / .FV   : 3D-Coordinate   : [Npoint 3]  [m]
        .LF   / .RF   / .FF   : Patch index     : [Npatch 4]
        .Limg / .Rimg / .Fimg : 3D RGB image    : [Npoint 3]
 LR    = 'L' or 'R' or 'F' : Left/Right/Front
 --- Output
 V : 3D coordinate corresponding to view point 'Left/Right/Front'
 X : X-coordinate in projected 2D screen-space
 Y : Y-coordinate in projected 2D screen-space
 Z : Z-coordinate = 0 
 F : patch index
 C : Color of vertex

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [V,F,C,X,Y,Z] = vb_get_vivid_proj(Coord, LR)
0002 % Project SPM-R coordinate to 2D screen
0003 %  [V,F,C,X,Y,Z] = vb_get_vivid_proj(Coord, LR)
0004 % --- Input
0005 % Coord : Left / Right /Front  head coordinate
0006 %  'MGF'- File
0007 %        .LV   / .RV   / .FV   : 3D-Coordinate   : [Npoint 3]  [m]
0008 %        .LF   / .RF   / .FF   : Patch index     : [Npatch 4]
0009 %        .Limg / .Rimg / .Fimg : 3D RGB image    : [Npoint 3]
0010 % LR    = 'L' or 'R' or 'F' : Left/Right/Front
0011 % --- Output
0012 % V : 3D coordinate corresponding to view point 'Left/Right/Front'
0013 % X : X-coordinate in projected 2D screen-space
0014 % Y : Y-coordinate in projected 2D screen-space
0015 % Z : Z-coordinate = 0
0016 % F : patch index
0017 % C : Color of vertex
0018 %
0019 % Copyright (C) 2011, ATR All Rights Reserved.
0020 % License : New BSD License(see VBMEG_LICENSE.txt)
0021 
0022 % SPM-R
0023 %   X: 左->右   Left(-191/2)   -> Right(191/2)
0024 %   Y: 後->前   Back(-256/2)   -> Front(256/2)
0025 %   Z: 下->上   Bottom(-256/2) -> Top(256/2)
0026 %
0027 %view([-90, 0]);    % Left view  (from -X axis)
0028 %view([ 90, 0]);    % Right view (from +X axis)
0029 %view([180, 0]);    % Front view (from +Y axis)
0030 %view([  0, 90]);   % Top view   (from +Z axis)
0031 
0032 angleL = [-90, 0];
0033 angleR = [ 90, 0];
0034 angleF = [180, 0];
0035 
0036 switch    LR
0037 case    'L'
0038     V = Coord.LV;
0039     F = Coord.LF;
0040     C = Coord.Limg;
0041     T = viewmtx(angleL(1),angleL(2));
0042 case    'R'
0043     V = Coord.RV;
0044     F = Coord.RF;
0045     C = Coord.Rimg;
0046     T = viewmtx(angleR(1),angleR(2));
0047 case    'F'
0048     V = Coord.FV;
0049     F = Coord.FF;
0050     C = Coord.Fimg;
0051     T = viewmtx(angleF(1),angleF(2));
0052 end
0053 
0054 NV = size(V,1);
0055 X  = [V ones(NV,1)]*T(1,:)';
0056 Y  = [V ones(NV,1)]*T(2,:)';
0057 Z  = zeros(NV,1);
0058 
0059 return
0060 %%%%%%%%%%%%%%%%%%% END %%%%%%%%%%%%%%%%%%%%
0061 
0062 h = figure;
0063 
0064 subplot(1,2,1)
0065 % Plot face on projected 2D screen
0066 patch('Faces',F,'Vertices',[X Y Z],'FaceColor','interp',...
0067     'FaceVertexCData',C,'EdgeColor','none',...
0068     'FaceLighting','none');
0069 hold on
0070 view([ 0, 90]);
0071 axis equal
0072 
0073 subplot(1,2,2)
0074 % Plot 3D face
0075 patch('Faces',F,'Vertices',V,'FaceColor','interp',...
0076     'FaceVertexCData',C,'EdgeColor','none',...
0077     'FaceLighting','none');
0078 hold on
0079 view(T);
0080 axis equal
0081 
0082 return

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005