function [pixelvalue] = bilateral_filter(Image, x, y)

%Gets a pixel value at x and y, and returns a bilateral filtered pixel at same location.

gMatrix = getGfunction(Image, x, y);
iMatrix = getIfunction(Image, x, y);
fMatrix = fspecial('gaussian');

jMatrix = fMatrix .* gMatrix .* iMatrix;
tMatrix = fMatrix .* gMatrix;

temp = sum(sum(jMatrix));

kOfS = sum(sum(tMatrix));

temp2 = 0;
normal = 0;

for i=1:size(jMatrix,1)
    for j=1:size(jMatrix,2)
        
        temp2 = temp2 + jMatrix(i,j);
        normal = normal + tMatrix(i,j);
        
    end
end



pixelvalue = temp ./ kOfS;
%pixelvalue2 = temp2 ./ normal




