How to implement convolution instead of the built-in imfilter
이전 댓글 표시
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
Valeska Pearson
2013년 7월 10일
Chad Gilbert
2013년 7월 10일
Are you happy to use conv2? Or are you avoiding it along with imfilter?
Image Analyst
2013년 7월 10일
Don't do that - it's not linear filtering, that's masking. See my demo below.
Ferdie
2013년 7월 11일
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.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
