Home > vbmeg > functions > common > morphology > vb_subsample_3d.m

vb_subsample_3d

PURPOSE ^

subsampling by half

SYNOPSIS ^

function B = vb_subsample_3d(B)

DESCRIPTION ^

 subsampling by half
  B = vb_subsample_3d(B)
  B : 3D-image

 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_subsample_3d(B)
0002 % subsampling by half
0003 %  B = vb_subsample_3d(B)
0004 %  B : 3D-image
0005 %
0006 % Copyright (C) 2011, ATR All Rights Reserved.
0007 % License : New BSD License(see VBMEG_LICENSE.txt)
0008 
0009 [N1,N2,N3] = size(B);
0010 
0011 if mod(N1,2) ~= 0,
0012     B = cat(1, B, zeros(1,N2,N3));
0013     N1= N1+1;
0014 end
0015 
0016 if mod(N2,2) ~= 0,
0017     B = cat(2, B, zeros(N1,1,N3));
0018     N2= N2+1;
0019 end
0020 
0021 if mod(N3,2) ~= 0,
0022     B = cat(3, B, zeros(N1,N2,1));
0023     N3= N3+1;
0024 end
0025 
0026 % データの間引き間隔
0027 % subsampling step
0028 step = 2;
0029 
0030 % neighbor index list for boundary detection
0031 % (X-axis) 隣接点インデックス
0032 j1d = 1:step:(N1-1);
0033 j1u = 2:step:N1;
0034 % (Y-axis) 隣接点インデックス
0035 j2d = 1:step:(N2-1);
0036 j2u = 2:step:N2;
0037 
0038 % 前後左右上下に動かし平均化
0039 for zz = 1:N3
0040     B(j1d, : , zz ) = B(j1d, : , zz ) + B(j1u, : , zz );
0041 end
0042 
0043 for zz = 1:N3
0044     B( : ,j2d, zz ) = B( : ,j2d, zz ) + B( : ,j2u, zz );
0045 end
0046 
0047 for zz = 1:(N3-1)
0048     B(:,:,zz) = B(:,:,zz) + B(:,:,zz+1);
0049 end
0050 
0051 % データの間引き
0052 % subsampling
0053 B = B(1:step:N1,1:step:N2,1:step:N3)/8;
0054 
0055

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005