function [bs, bm, bmaps] = bias3d(x, y, ws, absval)
% Focal Bias for 3D images/arrays (m*n*z)
% 27/01/2013 - Version 1.0
% 21/02/2013 - Version 2.0
% Author: Aristidis D. Vaiopoulos
if nargin == 2
ws = 8;
absval = 1;
end
if nargin == 3
absval = 1;
end
% Find dimensions
sizex = size(x);
sizey = size(y);
if ~isequal(sizex,sizey)
error('Images must have equal dimensions.')
end
% Number of bands
nb = size(x,3);
% Preallocate mean bs
bs = zeros(nb,1);
if nargout == 3
% Preallocate bmaps (memory voracious)
bmaps = single(zeros(sizex));
for b = 1:nb
[bs(b), bmaps(:,:,b)] = bias_fs( x(:,:,b),y(:,:,b),ws,absval );
end
else
for b = 1:nb
bs(b) = bias_fs( x(:,:,b),y(:,:,b),ws,absval );
end
end
% Average quality
bm = mean(bs);
end