Home > functions > common > morphology > vb_surf_to_filled_mask.m

vb_surf_to_filled_mask

PURPOSE ^

Make filled mask image from surface cordinate

SYNOPSIS ^

function [B] = vb_surf_to_filled_mask(V, F, Dim, step, Radius, X0)

DESCRIPTION ^

 Make filled mask image from surface cordinate
  [B] = vb_surf_to_filled_mask(V, F, Dim, step, X0, Radius)
 --- Input
 V   : surface vertex point cordinate   [Nvertex, 3]
 F    : Patch index structure
 Dim  : mask image dimension
 --- Optional Input
 step = 2   : voxcel size [mm]
 Radius = [ 4 -4 ] : morphological smoothing [mm]
        = [ 6 ]    : morphological extraction
        = []       : No morphological operation
 X0  ; start point to filling in
--- Output 
 B(nx,ny,nz) : mask image
 size(B) = Dim

 2007-3-16 M. 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_surf_to_filled_mask(V, F, Dim, step, Radius, X0)
0002 % Make filled mask image from surface cordinate
0003 %  [B] = vb_surf_to_filled_mask(V, F, Dim, step, X0, Radius)
0004 % --- Input
0005 % V   : surface vertex point cordinate   [Nvertex, 3]
0006 % F    : Patch index structure
0007 % Dim  : mask image dimension
0008 % --- Optional Input
0009 % step = 2   : voxcel size [mm]
0010 % Radius = [ 4 -4 ] : morphological smoothing [mm]
0011 %        = [ 6 ]    : morphological extraction
0012 %        = []       : No morphological operation
0013 % X0  ; start point to filling in
0014 %--- Output
0015 % B(nx,ny,nz) : mask image
0016 % size(B) = Dim
0017 %
0018 % 2007-3-16 M. Sato
0019 %
0020 % Copyright (C) 2011, ATR All Rights Reserved.
0021 % License : New BSD License(see VBMEG_LICENSE.txt)
0022 
0023 if nargin < 3, error('Input arguments is wrong'); end;
0024 if ~exist('step','var'), step = 2; end
0025 if ~exist('Radius','var'), Radius  = [4 -4 ];end
0026 
0027 %%% DEBUG
0028 Debug_mode = 0;
0029 
0030 %
0031 % Closed surface check
0032 %
0033 disp('--- Closed surface check');
0034 omega = vb_solid_angle_check(V,F);
0035 
0036 fprintf('Solid angle = 4pi x %f\n',omega);
0037 if abs(omega-1)>1e-10, 
0038   disp('Surface is not closed.');
0039   return;
0040 else
0041   disp('Surface is closed.');
0042 end
0043 
0044 %
0045 %-------- 表面をマスクに変換
0046 %
0047 fprintf('--- Make mask image from surface\n')
0048 dmin = step/2;    % 三角形分割長さ
0049 
0050 B = vb_surf_to_mask(V, F, step, dmin, Dim);
0051 
0052 %
0053 %------- 内部点を塗りつぶす
0054 %
0055 fprintf('--- Fill out inside the surface \n')
0056 
0057 filval = 1;        % 内部点マスクの値
0058 level  = 0.5;    % この値より小さい値を塗りつぶす
0059 
0060 if ~exist('X0','var')
0061     X0  = fix(mean(V/step));    % 中心点
0062 end
0063 
0064 B   = vb_flood_fill_3d(B, X0, filval, level);
0065 
0066 if Debug_mode == 2, return; end
0067 %
0068 % --- Apply morphology erosion
0069 %
0070 B = vb_morphology_operation(B, Radius, step);
0071 
0072 return
0073 % --- END ---
0074 
0075 if Debug_mode == 1, return; end
0076 
0077 % 3次元データの平滑化
0078 tic
0079 fprintf('smoothing\n')
0080 B = smooth3(B,'gaussian',3);
0081 vb_ptime(toc);

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