function G = CS6640_Gaussian2D(sigma, height, width)
% CS6640_Gaussian2D - 2D Gaussian function
% On input:
%     sigma (float): Standard deviation of the Gaussian
%     height (int): Height (num. rows) of the output
%     width (int): Width (num cols) of the output
% On output:
%     G (height x width array): Gaussian
% Call:
%     em = CS6640_Gaussian2D(100, 640, 480);
% Author:
%     N. Marshak
%     UU
%     Fall 2020
%
     
    Q = height;
    P = width;
    D_o = sigma;
    
    % See p. 278 of Gonzalez and Wood
    D = zeros(Q,P); %D defined on p. 273
    center = [(Q+1)/2; (P+1)/2];
    for i=1:Q
        for j=1:P
            position = [i; j] - center;
            D(i,j) = norm(position);
        end
    end

    G = exp(-D.^2/(2*D_o^2));
end

