Home > functions > common > morphology > vb_make_mask_from_vertex.m

vb_make_mask_from_vertex

PURPOSE ^

Make mask from vertex coordinate

SYNOPSIS ^

function B = vb_make_mask_from_vertex(Vdim, XYZ, Z)

DESCRIPTION ^

 Make mask from vertex coordinate
  B = vb_make_mask_from_vertex(Vdim, XYZ, Z)
 Vdim : mask image dimension
 XYZ  : vertex coordinate of mask point [Npoint x 3]
  Z   : mask value for XYZ
  B   : mask image

 2007/06/09 Masa-aki Sato

 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    B = vb_make_mask_from_vertex(Vdim, XYZ, Z)
0002 % Make mask from vertex coordinate
0003 %  B = vb_make_mask_from_vertex(Vdim, XYZ, Z)
0004 % Vdim : mask image dimension
0005 % XYZ  : vertex coordinate of mask point [Npoint x 3]
0006 %  Z   : mask value for XYZ
0007 %  B   : mask image
0008 %
0009 % 2007/06/09 Masa-aki Sato
0010 %
0011 % Copyright (C) 2011, ATR All Rights Reserved.
0012 % License : New BSD License(see VBMEG_LICENSE.txt)
0013 
0014 if ~exist('Z','var'), Z = ones(size(XYZ,1),1); end;
0015 
0016 XYZ = fix(XYZ);
0017 
0018 ix = find(  XYZ(:,1) >=1  & XYZ(:,1) <= Vdim(1) ...
0019           & XYZ(:,2) >=1  & XYZ(:,2) <= Vdim(2) ...
0020           & XYZ(:,3) >=1  & XYZ(:,3) <= Vdim(3) );
0021 
0022 Npoint = length(ix);
0023 
0024 XYZ = XYZ(ix,:);
0025 Z   = Z(ix);
0026 
0027 B = zeros(Vdim);
0028 
0029 for n=1:Npoint
0030     B(XYZ(n,1), XYZ(n,2), XYZ(n,3)) = Z(n);
0031 end

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