Describe what the following MATLAB code does. the original function name has bee
ID: 3671238 • Letter: D
Question
Describe what the following MATLAB code does. the original function name has been replaced by f name. Specify where relevant which expressions in the textbook have been implemented. 20 points function [g x, g y] f name (IM, sigma) % (comment taken out) % [gx.gyl f name(IM, sigma) (comment taken out) epsilon =1e-2; half size=ceil(sigma sqrt(2 pi) sigma epsilon))); size =2 halfsize+1; %(comment taken out) for I =1:size for j=1:size u=[i-halfsize-1j-halfsize -1];h x(I, j)= gauss(u(1)sigma d gauss(u(2),sigma); end h x = h x/sqrt(sum(abs(h x)abs(h x)))); %(comment taken out) g x=Im filter(IM, h x, replicate, con'); g y=I m filter ; function y= gauss(x, sigma) %(comment taken out) y =exp(-x^2(2 sigma sqrt (2 pi)); function y= d gauss(x, sigma) %(comment taken out) y= x gauss (x, sigma/sigma^ 2;Explanation / Answer
Guassian law modiefied
function [gx,gy]=gaussgradient(IM,sigma)
%GAUSSGRADIENT Gradient using first order derivative of Gaussian.
% [gx,gy]=gaussgradient(IM,sigma) outputs the gradient image gx and gy of
%size.
epsilon=1e-2;
halfsize=ceil(sigma*sqrt(-2*log(sqrt(2*pi)*sigma*epsilon)));
size=2*halfsize+1;
%generate a 2-D Gaussian kernel along x direction
for i=1:size
for j=1:size
u=[i-halfsize-1 j-halfsize-1];
hx(i,j)=gauss(u(1),sigma)*dgauss(u(2),sigma);
end
end
hx=hx/sqrt(sum(sum(abs(hx).*abs(hx))));
%generate a 2-D Gaussian kernel along y direction
hy=hx';
%2-D filtering
gx=imfilter(IM,hx,'replicate','conv');
gy=imfilter(IM,hy,'replicate','conv');
function y = gauss(x,sigma)
%Gaussian
y = exp(-x^2/(2*sigma^2)) / (sigma*sqrt(2*pi));
function y = dgauss(x,sigma)
%first order derivative of Gaussian
y = -x * gauss(x,sigma) / sigma^2;