clc;
clear all;
clc;
img = imread ('a.jpg');
img = rgb2gray(img);
figure, imshow(img);
img = double (img);
sigma= 2;
G= zeros(5,5);
for i=1:5
for j=1:5
x=[-2,1,0,-1,2];
y=[-2,1,0,-1,2];
G(i,j)= exp(-(x(i)^2+y(j)^2)/(2*(sigma^2)));
end
end
G_=G/sum(sum(G,1),2);
A= conv2(img,G);
figure, imshow(A);
This is my code for image smoothing. I first calculated Gaussian Filter Coefficient Coefficient that is normalized.
For the last line, I tried to do convolution of image by the Gaussian Filter Coefficient, then show the image. However, it only shows a white empty image. I think the value for Gaussian Filter Coefficient is correct, so I think the problem is on convolution.
Isn't convolution done by conv2(u,v) on matlab? What am I doing wrong?