%% zoom_out_x2_3D.m
%
% E. Koenig, 08/04/2010
%
% Zoom out of a 3D field to a lower resolution.
%
% The new resolution is 2 times lower than the initial one.
% The zoom out is realized by aggregating voxels.
%
%
%% Use
%
% I_out = zoom_out_x2_3D(I);
%
%
%% Inputs
%
% * *I*:  input 3D field.
%
%
%% Outputs
%
% * *I_out*: lower resolution 3D field.
%
%
%% Example
%
% Zoom out of a 8x8x8 random field:
%
%   I = randn(8,8,8);
%   I_out = zoom_out_x2_3D(I);




function I_out = zoom_out_x2_3D(I)


I_conv = convn(I,ones(2,2,2),'valid');  % integration
clear I
I_conv_dec = I_conv(1:2:end,1:2:end,1:2:end);     % decimation

clear I_conv

I_out = I_conv_dec;


clear I_conv_dec

