Home > functions > device > vivid > vb_get_ref_point.m

vb_get_ref_point

PURPOSE ^

Get marker 3D coordinate from the VIVID 2D-image by mouse click

SYNOPSIS ^

function Vp = vb_get_ref_point(Coord, LR, mtype)

DESCRIPTION ^

 Get marker 3D coordinate from the VIVID 2D-image by mouse click
   Vp = vb_get_ref_point(Coord, 'L')   for Left  Face
   Vp = vb_get_ref_point(Coord, 'R')   for Right Face

 Coord : Vivid coordinate
 LR    : Left/Right
 mtype ; Marker type and size (structure)

 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    Vp = vb_get_ref_point(Coord, LR, mtype)
0002 % Get marker 3D coordinate from the VIVID 2D-image by mouse click
0003 %   Vp = vb_get_ref_point(Coord, 'L')   for Left  Face
0004 %   Vp = vb_get_ref_point(Coord, 'R')   for Right Face
0005 %
0006 % Coord : Vivid coordinate
0007 % LR    : Left/Right
0008 % mtype ; Marker type and size (structure)
0009 %
0010 % Copyright (C) 2011, ATR All Rights Reserved.
0011 % License : New BSD License(see VBMEG_LICENSE.txt)
0012 
0013 if ~exist('mtype','var')
0014     msize1 = 15;
0015     mtype1 = '.y';
0016     msize2 = 20;
0017     mtype2 = '.r';
0018 else
0019     msize1 = mtype.msize1;
0020     mtype1 = mtype.mtype1;
0021     msize2 = mtype.msize2;
0022     mtype2 = mtype.mtype2;
0023 end
0024 
0025 if isfield(Coord, 'FV')
0026     NX  = 3;
0027     NY  = 2;
0028     Flg = 1;
0029 else
0030     NX  = 2;
0031     NY  = 2;
0032     Flg = 0;
0033 end
0034 
0035 switch    LR
0036 case    'L'
0037     Nfig = 1;
0038     V = Coord.LV;
0039     X = Coord.LX;
0040     Y = Coord.LY;
0041 case    'F'
0042     if Flg == 1,
0043         Nfig = 2;
0044         V = Coord.FV;
0045         X = Coord.FX;
0046         Y = Coord.FY;
0047     else
0048         Nfig = 1;
0049         V = Coord.LV;
0050         X = Coord.LX;
0051         Y = Coord.LY;
0052     end
0053 case    'R'
0054     if Flg == 1,
0055         Nfig = 3;
0056     else
0057         Nfig = 2;
0058     end
0059     V = Coord.RV;
0060     X = Coord.RX;
0061     Y = Coord.RY;
0062 end
0063 
0064 figure(gcf);
0065 %
0066 % Left/Right face
0067 %
0068 subplot(NY,NX,Nfig)
0069 
0070 % Input marker position  by mouse click
0071 [xp,yp] = ginput(1);
0072 
0073 % Find nearest 3D & 2D-coordinate to the target point
0074 [Vp, Xp, Yp, dmin] = vb_get_3d_point([xp,yp],V,X,Y);
0075 
0076 % Plot marker on 2D-image
0077 plot(Xp,Yp,mtype1,'MarkerSize',msize1);
0078 
0079 % Plot marker on 3D face
0080 subplot(NY,NX,Nfig+NX)
0081 plot3(Vp(:,1),Vp(:,2),Vp(:,3),mtype2,'MarkerSize',msize2);

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005