Home > functions > common > morphology > vb_morphology_operation.m

vb_morphology_operation

PURPOSE ^

Dilation/erosion are done consecutively according to Radius

SYNOPSIS ^

function B = vb_morphology_operation(B, Radius, step, plot_mode, zindx, Nfig)

DESCRIPTION ^

 Dilation/erosion are done consecutively according to Radius
  B = vb_morphology_operation(B, Radius, step)
-------- モルフォロジー変換 --------
 [IN]  B         : 3D-Image data
 [IN]  Radius    : Radius of Morfology operation 
 [IN]  step      : subsampling step size 

 [OUT] B         : 3D-Image data

 穴埋め・孤立点削除 (モルフォロジー) 変換の順序と半径
 ---- Define order and size of dilation/erosion by Radius ----

 Radius : Radius of Morfology operation
 -- Example
 Radius = [ -2 2 ];
 R > 0  : dilation
 R < 0  : erosion
 1. remove small island in background  (R = -2,  2)
 2. fill holes inside the brain        (R =  6, -6)

 -- Optional input
 [IN]  plot_mode : Plot slice image.(0-2 : No,  3 : Yes)
 [IN]  zindx     : スライス画像表示の Z-座標リスト
 [IN]  Nfig      : number of subplot

 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    B = vb_morphology_operation(B, Radius, step, plot_mode, zindx, Nfig)
0002 % Dilation/erosion are done consecutively according to Radius
0003 %  B = vb_morphology_operation(B, Radius, step)
0004 %-------- モルフォロジー変換 --------
0005 % [IN]  B         : 3D-Image data
0006 % [IN]  Radius    : Radius of Morfology operation
0007 % [IN]  step      : subsampling step size
0008 %
0009 % [OUT] B         : 3D-Image data
0010 %
0011 % 穴埋め・孤立点削除 (モルフォロジー) 変換の順序と半径
0012 % ---- Define order and size of dilation/erosion by Radius ----
0013 %
0014 % Radius : Radius of Morfology operation
0015 % -- Example
0016 % Radius = [ -2 2 ];
0017 % R > 0  : dilation
0018 % R < 0  : erosion
0019 % 1. remove small island in background  (R = -2,  2)
0020 % 2. fill holes inside the brain        (R =  6, -6)
0021 %
0022 % -- Optional input
0023 % [IN]  plot_mode : Plot slice image.(0-2 : No,  3 : Yes)
0024 % [IN]  zindx     : スライス画像表示の Z-座標リスト
0025 % [IN]  Nfig      : number of subplot
0026 %
0027 % Made by M. Sato 2004-3-28
0028 %
0029 % Copyright (C) 2011, ATR All Rights Reserved.
0030 % License : New BSD License(see VBMEG_LICENSE.txt)
0031 
0032 %
0033 %-------- モルフォロジー変換 --------
0034 %
0035 if  ~exist('plot_mode','var'), plot_mode = 0; end;
0036 if  ~exist('step','var'), step = 1; end;
0037 
0038 % Radius of Morfology operation
0039 R = Radius/step; 
0040 
0041 Nclose = length(R);
0042 
0043 if Nclose == 0, return; end;
0044 
0045 if plot_mode == 3,
0046     NY = 2;
0047     NX = ceil(Nclose/NY);
0048     figure;
0049 end
0050 
0051 %tic
0052 
0053 for n = 1:Nclose
0054 
0055     if R(n) == 0,
0056         continue;
0057     elseif R(n) < 0,
0058         % 境界削除 (Erosion)
0059         fprintf('erosion (R = %f)\n',R(n)*step)
0060         B = vb_erosion_3d(B, abs(R(n)));
0061         %vb_ptime(toc);tic
0062     else
0063         % 境界拡張 (Dilation)
0064         fprintf('dilation (R = %f)\n',R(n)*step)
0065         B = vb_dilation_3d(B, R(n));
0066         %vb_ptime(toc);tic
0067     end
0068     
0069     if plot_mode == 3
0070         subplot(NY,NX,n)
0071         plot_one_slice(B);
0072         title(sprintf('R = %f\n',R(n)*step))
0073     end
0074 end
0075 
0076 %vb_ptime(toc);
0077 
0078 if  plot_mode > 1,
0079     % Z-coordinate for slice plot
0080     if ~exist('zindx','var'), zindx = [40:20:200]; end;
0081     if ~exist('Nfig','var'),  Nfig  = [3, 3]; end;
0082     
0083     % スライス画像表示の Z-座標リスト
0084     zindx = round(zindx/step);
0085 
0086     vb_plot_slice( B, [], zindx, 1, Nfig);
0087 end
0088 
0089 % # of on voxcel in each slice
0090 %Nvoxel = squeeze( sum(sum(B,2),1) );
0091 %

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