0001 function B = vb_subsample_3d(B)
0002
0003
0004
0005
0006
0007
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
0028 step = 2;
0029
0030
0031
0032 j1d = 1:step:(N1-1);
0033 j1u = 2:step:N1;
0034
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
0053 B = B(1:step:N1,1:step:N2,1:step:N3)/8;
0054
0055