How to implement convolution instead of the built-in imfilter
Mostrar comentarios más antiguos
m=13; n=13;
sigma=15;
[h1 h2]=meshgrid(-(m-1)/2:(m-1)/2, -(n-1)/2:(n-1)/2);
hg= exp(-(h1.^2+h2.^2)/(2*sigma^2)); %Gaussian function
h=hg ./sum(hg(:));
Now I want to use these Gaussian kernels to implement linear filtering with on image
OriginalRGB = imread('LeerNaam.png'); % read image
filter=h; s = size(OriginalRGB);
r = zeros(s);
for i = 2:s(1)-1
for j = 2:s(2)-1
temp = OriginalRGB(i-1:i+1,j-1:j+1)) .* filter;
r(i,j) = sum(temp(:));
end
end
4 comentarios
Valeska Pearson
el 10 de Jul. de 2013
Chad Gilbert
el 10 de Jul. de 2013
Are you happy to use conv2? Or are you avoiding it along with imfilter?
Image Analyst
el 10 de Jul. de 2013
Don't do that - it's not linear filtering, that's masking. See my demo below.
Ferdie
el 11 de Jul. de 2013
Thanks... The reason for not implementing imfilter is because I need to know what imfilter does. It is for a project and I can't just use built-in functions.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Image Processing Toolbox en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
