function G = gaussian2D( R, C, var )
%first create a gaussian over a single row
%then extend it as a 2D gaussian by multiplying by a single column
%gaussian
%take mean as the center pixel
mean = (C+1)/2;
%make the middle row 1D gaussian
G = [ 1:C ];
G = ( 1 / (var * ( (2*pi )^0.5 ) ) ) .* exp( -1 .* ( ( (G - mean).^2 ) ./ (2 * var^2) ) );
%make a column 1D gaussian
mean = (R+1)/2;
G_c = [ 1:R ];
G_c = ( ( 1 / (var * ( (2*pi )^0.5 ) ) ) .* exp( -1 .* ( ( (G_c - mean).^2 ) ./ (2 * var^2) ) ) )';
%multiply the row and column gaussian to get the 2D gaussian
G = G_c * G;
%since its an averaging filter it should add up to one
%for this we normailze by dividing by the total matrix sum
G = G ./ sum(sum(G));