function [mass_x, mass_y] = find_center(MASK)
% MASK: logical array (only zeros and ones).
%
% mass_x: coordinate of center of mass (horizontal), integer
% mass_y: coodrinate of center of mass (vertical), integer
    
    x = 1:size(MASK,1);
    y = 1:size(MASK,2);
    [X,Y] = meshgrid(x,y);
    
    X_masked = X' .* MASK;
    Y_masked = Y' .* MASK;
    
    mass_y = round(sum(X_masked(:)) / sum(MASK(:)));
    mass_x = round(sum(Y_masked(:)) / sum(MASK(:)));
    
end