Home > functions > common > morphology > vb_flood_fill_3d.m

vb_flood_fill_3d

PURPOSE ^

flood_fill

SYNOPSIS ^

function V = vb_flood_fill_3d(V,indx,fillval,level)

DESCRIPTION ^

 flood_fill
  V = vb_flood_fill_3d(V,indx,fillval,level)
 閾値'level'より小さい値を持つボクセルを'fillval'で塗りつぶす
 
 V    = 3D イメージ
 V(x,y,z) : 点(x,y,z)における値

 indx = [xc,yc,zc] 初期ルートインデックス
 fillval: 塗りつぶす値 > level
 level  : 閾値

 Made by M. Sato 2004-3-28

 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 = vb_flood_fill_3d(V,indx,fillval,level)
0002 % flood_fill
0003 %  V = vb_flood_fill_3d(V,indx,fillval,level)
0004 % 閾値'level'より小さい値を持つボクセルを'fillval'で塗りつぶす
0005 %
0006 % V    = 3D イメージ
0007 % V(x,y,z) : 点(x,y,z)における値
0008 %
0009 % indx = [xc,yc,zc] 初期ルートインデックス
0010 % fillval: 塗りつぶす値 > level
0011 % level  : 閾値
0012 %
0013 % Made by M. Sato 2004-3-28
0014 %
0015 % Copyright (C) 2011, ATR All Rights Reserved.
0016 % License : New BSD License(see VBMEG_LICENSE.txt)
0017 
0018 % Vflag  : 塗りつぶされたボクセルのマスクパターン
0019 
0020 [NX,NY,NZ] = size(V);
0021 
0022 xc = indx(1);
0023 yc = indx(2);
0024 zc = indx(3);
0025 
0026 % Vflag0: 塗りつぶされたボクセルの 2D マスクパターン
0027 [V(:,:,zc), Vflg0] = vb_flood_fill_2d(V(:,:,zc),[xc yc],fillval,level);
0028 
0029 Vflg = Vflg0;
0030 
0031 for n=(zc+1):NZ
0032     % z = (n-1) で塗りつぶされたパターンを抽出し
0033     ix = find( Vflg > 0);
0034 
0035     % z = n での塗りつぶし点の初期値
0036     % [i,j] = ind2sub([NX,NY],ix) の高速計算
0037     j  = floor((ix-1)/NX)+1;
0038     i  = rem((ix-1),NX)+1;
0039 
0040     % 2D 塗りつぶし
0041     [V(:,:,n), Vflg] = vb_flood_fill_2d(V(:,:,n),[i,j],fillval,level);
0042 end
0043 
0044 Vflg = Vflg0;
0045 
0046 for n=(zc-1):-1:1
0047     % z = (n+1) で塗りつぶされたパターンを抽出
0048     ix = find( Vflg > 0);
0049 
0050     % z = n での塗りつぶし点の初期値
0051     % [i,j] = ind2sub([NX,NY],ix) の高速計算
0052     j  = floor((ix-1)/NX)+1;
0053     i  = rem((ix-1),NX)+1;
0054 
0055     % 2D 塗りつぶし
0056     [V(:,:,n), Vflg] = vb_flood_fill_2d(V(:,:,n),[i,j],fillval,level);
0057 end

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